lua-users home
lua-l archive

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


On Fri, Nov 12, 2004 at 03:55:26PM -0200, Roberto Ierusalimschy wrote:

> Please let us stop this discussion. I guess every one that could be
> convinced of anything already is.

Good call, Roberto.

This might have been a useful little experience though, in that it
highlighted how discussions can go wrong (and serve little purpose)
when the focus isn't on the programming but on debating and defense.

Let's try to stick to the programming and specifically to Lua, not
to the meaning of words.  No language wars, just understanding Lua.

*************
This is the important fact about Lua closures that Lua users
must keep in mind to avoid very nasty bugs:  you cannot create
a Lua closure and then forget about it, expecting the invariant
referential transparency of a pure functional closure to hold.
*************

To achieve that requires special programming, ie. ensuring that nothing
else has access to the scope that these functions carry with them.

This is an important fact of Lua behaviour, and whether one regards it
as a feature or a problem is not as important as understanding how it
works in practice.  And stating it clearly.  That's even-handed.

I hope that the next edition of PiL documents both the benefits and the
restrictions of Lua closures.  Understanding both is important.

As defined, Lua closures work just fine, and efficiently.

To an engineer, a constraint is not a problem as long as it is identified.

Rich Artym.
-- 
Existing media are so disconnected from reality that our policy debates
spin around a fantasy world in which the future looks far too much like
the past.   http://www.zyvex.com/nanotech/MITtecRvwSmlWrld/article.html