lua-users home
lua-l archive

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


Making all globals read-only by default seemed like a good solution to me.
Then 'global x' gives you write access to the global.

Of course you can have a 'local' key word which then switches off write
access to a global.

Russ

> From: Reuben Thomas <rrt1001@cam.ac.uk>
> Reply-To: lua-l@tecgraf.puc-rio.br
> Date: Wed, 31 Jan 2001 10:22:19 +0000 (GMT)
> To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
> Subject: Re: Son of Lua - Sol
> 
>> The main thing I did was to make a 'global' keyword and make Lua default to
>> creating locals inside a function, of course read access to globals was
>> still there by default (in one version just for global functions):
>> 
>> b = 10
>> c = 1
>> function test(x)
>> global c;
>> b = "this does not change the global";
>> c = "but this does";
>> print(10); -- this uses the read access to globals
>> end
> 
> I was wondering about doing this the other day; this is the sort of thing
> I'd love to see too.
> 
> I'd not thought of the problem that you really want global functions to be
> implicitly available, but not global variables, but of course there's no
> difference between them in Lua (it's the type of the contents of the
> variable, not that of the variable itself). Nasty...
> 
> -- 
> http://sc3d.org/rrt/ | Caution Children At Play Drive Slowly
>