[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: proposal (RE: Making vars local by default)
- From: Tom _ <tom7ca@...>
- Date: Thu, 31 May 2001 23:04:58 -0700 (PDT)
> >Nobody who doesn't want to would have to switch to
> >using ":=". Code that uses "=" would continue to
> >work and seamlessly work with code that uses ":=".
> >"x := y" would simply be a shorthand for "put
> >'local x' at the beginning of the function and
> >write 'x = y'".
>
> That's not the whole picture: from then on both
> coding styles would start
> to proliferate and gradually become part of libs,
> tools, etc... :(
What I proposed allows the two styles to co-exist
and interoperate. That removes the objection that
such a change would break existing code.
Whether you want to allow the two styles to co-exist
indefinitely is a policy choice. Personally, I'd
prefer to see the current style become obsolete
in a release or two, but I see the two styles
co-existing as much less of a problem than just having
the current default, which I view as very dangerous.
> Assignment is not really the issue, let's please not
> overload that (quite standard) concept.
Yes, the issue is scoping. Having multiple
assignment operators for different scopes is
one well established approach to the problem
(cf. the "R" language).
> I really don't see what the big deal
> with globals is.
Scoping is a big deal because scoping
bugs are subtle and often show up out of nowhere
long after they were introduced. Lua is one
in a long, long line of languages that were
initially designed with convenient but
dangerous scoping rules; fixing something like
that is always painful, but it beats the
alternatives. Just think of the evolution of
scoping in languages like Lisp and Perl.
> Have you considered the following:
>
> function blah(...)
> local v = {}
> ...
> v.a = ...
> ... = v.b
> ...
> end
>
> Would that, plus "test/undefined.lua" perhaps, (at
> least partially) address your concerns?
Not only is that style expensive, it also clearly
makes a safe programming style second class and
therefore discourages its adoption by other authors
of Lua code and libraries.
Tom.
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/