[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: explanation of ":=" proposal+examples
- From: "Russell Y. Webb" <rw20@...>
- Date: Fri, 01 Jun 2001 01:33:33 -0700
> 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
system:
function f()
local x = 4
x = 3 -- is this legal?
end
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
compatibility).
So,
function backwards_assignment_syntax()
local x
global y
x = 4 -- local
y := 10 -- global
end
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
end
as would
function fff()
x := 4 -- local
y = 10 -- global
end
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.
Russ