lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
>
> One option would be to ban assignment to globals at all inside
> functions. Another option would be to only allow assignments to
> global variable previously seen in that chunk.

Another idea (though rather perlish):

1) A $ is allowed as the first char of an identifier.

2) A single $ is what is proposed as _ENV.

3) $name is syntactic sugar for $.name

4) Access to globals without using the $ is allowed until
   the parser sees the first $-identifier in a chunk.
   From that point on, access to globals without using
   the $ raises an "undefined local"-error.

5) Optional, not sure: Raise an "defined as local"-error
   on $name if name is a local.

No more confusion about local/global - globals start with
a $!  .oO(Maybe call them environment vars now *g*).

Ciao, ET.