[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Making Lua lexically scoped (was: Re: Proper tail recursion)
- From: "Jay Carlson" <nop@...>
- Date: Mon, 30 Jul 2001 08:44:46 -0400
John Ramsdell writes:
> By the way, the more I think about the suspected Python method for
> making that language lexically scoped, the more I like it. That is, I
> like the idea that a language is lexically scoped, but as sacrifice to
> allow efficient implementations, variables become immutable whenever
> they are referenced by a closure.
This gives me the creeps. To understand whether something is writable or
not you can't just look at its declaration; you have to inspect all of the
code inside its defining block. As you pointed out to me on Friday, the
compiler can figure this out at compile time, but it's hard to explain to
The way I think about Lua functions, btw, is that they are layer of sugar on
top of making apply-able tables, with the contents of the table consisting
of varname=initializer references, where the varnames come from all the
%upvars, and only the %upvars, mentioned in the body. Is this a good thing?
I dunno. The only way to make the sugar thinner is to require explicit
declaration of the %upvars as part of the function syntax, something like
"function (a1,a2) copying %uv1, %uv2 [...] end". This starts dancing around
the issue of first class environments....