lua-users home
lua-l archive

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


> > I'd be interested to know what you (or anyone else) thought of my proposal
> > on this subject (which was to make variables local by default); the
> > proposal is also on the Wiki, to save readers trawling through the archives.

[Roberto wrote]
> I did not understand how your proposal keeps backwards compatibility. Also,
> I think local by default give very strange results; but this is a matter of
> taste... Anyway, I think the main problem is not what is the default, but
> any default: if you want good check, you need a way to prevent implicit
> (default) declarations, no matter whether they are global or local.

I've finally found the time to give this message the time it deserves.
In answer to your points and questions:

1. My proposal does not keep full backward compatibility; instead, it
   keeps it in the special case code not inside a function, in that it
   makes variables local by default only inside functions. This means
   that configuration-style scripts can be written as before.

2. Local by default seems unnatural only if there is to you some
   obvious global scope. Using multiple Lua states and multiple
   threads within a state the idea of global starts to fragment; in
   this case, local by default seems sensible, and the obvious unit of
   locality is the current block. In particular, this helps keep
   referential transparency.

3. I think that the idea of preventing implicit declarations goes
   against the spirit of Lua.

-- 
http://sc3d.org/rrt/ | Si hoc legere scis nimium eruditionis habes (Anon)