[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: changes in 'require'
- From: Diego Nehab <diego@...>
- Date: Wed, 13 Jul 2005 12:13:28 -0400 (EDT)
Hi,
require"a.b.c.d"
try a.b.c.d
if not found, implicitly require"a.b.c.xxx"
try preload a.b.c.d
[...]
It's an optimized mix of the fixed name idea with Doug's "go up on
failure and retry" approach.
What do you mean by "optmized"?
Because it doesn't call require each time it retries "a.b.c.d". It just
checks the preload (after all, as he says, we don't expect one of
"a.b.c.d" ancestors to actually change the filesystem).
If it is going to use a.b.c.xxx, why not start trying it? It eliminates
the need to "retry" a.b.c.d. It is much simpler (less steps, no ifs):
require "a.b.c.d"
try "a.xxx"
try "a.b.xxx"
try "a.b.c.xxx"
really require "a.b.c.d"
I agree its simpler. However, now every successful require pays the
price of trying all its ancestors, even if none were found. I don't know
how bad that will be.
If it is too bad, how about adding just one "if", i.e., start the
ancestors only if the first attempt failed? Code is still simple...
Either way, I am happy.
[]s,
Diego.