lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>   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"?

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"

(In practice we seldom use four levels of nesting...)

-- Roberto