[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua Library Design Workshop
- From: Roberto Ierusalimschy <rieru@...>
- Date: Mon, 25 Feb 2002 13:59:42 -0600 (CST)
On Sun, 24 Feb 2002, John Belmonte wrote:
> We've come to it in a roundabout fashion, but it seems to me that the syntax
>
> global (T) *
>
> would be better recognized as:
>
> namespace T
Namespaces is only one of the uses of the global declaration. But remember
that, in Lua, almost every function is global (print, write, etc.), so
a simple "namespace T" would not be very helpful. Moreover, a simple
"namespace T" helps to define modules, but not to use them.
> However I'm not sure I understood the intended semantics of your proposal,
The semantics is: "global (exp) name-list" translates to
_temp = exp
after that, any use of a name in name-list is read as "_temp.name",
subjected to the usual visibility rules for variable declarations.
If name-list is '*', then the rule applies to any name not declared
in another local/global declaration. So,
> 1) the access rules apply not only when the module is
> executed, but also when functions defined within the module are
> executed,
Yes, if the functions are declared inside the scope of the global
declaration. (The change from "name" to "_temp.name" is done at compile
time...)
> 2) in nesting of dofile's/modules, the access rules properly nest.
Scopes in "dofile"s do not nest.
> If upvalues were any lesson, we'll end up with proper namespaces despite
> any contrary intentions ;-).
What do you call "proper namespace"?
-- Roberto