[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Redefining locals
- From: David Given <dg@...>
- Date: Fri, 12 Nov 2004 11:23:15 +0000
On Thursday 11 November 2004 21:22, Matt Hellige wrote:
[...]
> I think it would be nice for lua to adopt a similar policy for locals,
> as has been suggested by others. I'd like:
>
> local x = 3
> function f() print(x) end
> f()
> local x = 5
> f()
>
> to print '3, 5' instead of '3, 3'...
This strikes me as being counterintuitive. I expect the explicit use of local
to define a *new* variable. f() is defined using the old version of x as an
upvalue, so defining a new one would simply hide the old one from any further
code.
I don't know Scheme, but I do know ML, and I'd expect local to work like 'let
<var> = <value> in...' (except with mutable variables, of course).
--
+- David Given --McQ-+ "...it's not that well-designed GUI's are rare,
| dg@cowlark.com | it's just that the three-armed users GUI's are
| (dg@tao-group.com) | designed for are rare." --- Mike Uhl on a.f.c
+- www.cowlark.com --+