[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (work4) now available
- From: Peter Cawley <lua@...>
- Date: Tue, 10 Aug 2010 21:50:09 +0100
On Tue, Aug 10, 2010 at 9:45 PM, Shawn Fox <shawnkfox@gmail.com> wrote:
> I'd go the opposite way and require a special sigil character for local
> variables. One thing that seems to be forgotten here is that functions are
> also variables, so if you had to import all your variables in some way, you
> would also have to import functions as well. Having different rules for
> functions than regular variables would be a huge mess. I have no issue with
> global variables, but it would help a great deal if it was easier to
> distinguish between a local and a global by directly looking at their
> usage... perhaps if local variables require the use of a sigil character
> instead of relying on a declaration such as "local"
>
> -- assign 35 to local variable x
> $x = 35
>
> -- assign global x + local x to local y variable
> $y = x + $x
>
> -- assign global y = local y
> y = $y
In my opinion, requiring a sigil for locals makes the situation worse.
At the moment, if you're expecting a local, but make a typo, then you
get a global. With your proposed change, if you make a typo *OR*
forget the sigil, then you get a global. A good editor should be able
to offer different colouring for locals and globals, which gives the
benefit of letting you see what is local without having to decorate
names.
- References:
- Re: [ANN] Lua 5.2.0 (work4) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (work4) now available, Renato Maia
- Re: [ANN] Lua 5.2.0 (work4) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (work4) now available, Petite Abeille
- Re: [ANN] Lua 5.2.0 (work4) now available, Javier Guerra Giraldez
- Re: [ANN] Lua 5.2.0 (work4) now available, Everett L Williams II
- Re: [ANN] Lua 5.2.0 (work4) now available, Mark Hamburg
- Re: [ANN] Lua 5.2.0 (work4) now available, Petri Häkkinen
- Re: [ANN] Lua 5.2.0 (work4) now available, steve donovan
- Re: [ANN] Lua 5.2.0 (work4) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.2.0 (work4) now available, Everett L Williams II
- Re: [ANN] Lua 5.2.0 (work4) now available, David Kastrup
- Re: [ANN] Lua 5.2.0 (work4) now available, Everett L Williams II
- Re: [ANN] Lua 5.2.0 (work4) now available, Javier Guerra Giraldez
- Re: [ANN] Lua 5.2.0 (work4) now available, Everett L Williams II
- Re: [ANN] Lua 5.2.0 (work4) now available, Shawn Fox