lua-users home
lua-l archive

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


> So stated another way, this is a mapping from bare names in the current 
> scope to tables.

Yes.


> Usually some mapping that doesn't use the native tables is cause for 
> attention, but I understand in this case you want it to be efficient and 
> avoid the runtime lookup.

Not only that, but we also want "lexical binding". Any trick that we do
with the global table is really global. We want to be able to do "modular"
mappings.


> This means that the name-list must consist of literals. However dynamic
> routing is still possible, by mapping * to T and then doing tricks with
> T's metatable.

Sure.


> If I'm correct that the global statement only applies within the current 
> scope, then the functionality can't be wrapped by some higher level 
> system.  So it wouldn't be possible to do:
> 
>      FancyImport('foolib', {'a', 'b', 'c'}) -- use a, b, c from foolib

No, but you can go close to it:

  global (FancyImport'foolib') a, b, c


-- Roberto