lua-users home
lua-l archive

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

> Just to clarify, my proposal was different.  It
> was to leave the semantics of "=" unchanged
> and to use ":=" for local assignment.

I see.  Sorry for being dense.

I'll give it more thought.  What about old code like the following in your

function f()
local x = 4
    x = 3 -- is this legal?

It would need to be legal for any old code to work.

I guess a system of complete options would include:
1. 'local' and 'global' keywords
2. both = and := as you proposed (:= for local assignment)
3. both assignments (or maybe just '=') could be overridden with explicit
local or global keywords (note, overriding '=' is needed for backward


function backwards_assignment_syntax()
local x
global y
    x = 4   -- local
    y := 10 -- global

would work as would a style that never used := and always used the keywords

function ff()
local x
global y
    x = 4  -- local
    y = 10 -- global

as would

function fff()
    x := 4 -- local
    y = 10 -- global

Why impose a style?  Of course this does make it possible to write weird
looking code, but that's already possible.

I like it.  Though I'm not really convinced that a global keyword is
valuable, I'm just iterating over the options.