[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Blocks/Closures in Lua
- From: alan@... (Alan Watson)
- Date: Mon, 29 Dec 1997 10:42:06 -0600
> In the meantime, you can try using strings to define the functions to
> be passed.
For what it's worth, I've been using a function something like this
for a while:
"function _" .. body .. "; return _"
You can add whatever checks for errors you feel are appropriate. The
example being discussed would become:
lambda("(a) if a > 24 then a = a + 1 end end")
The advantages are that myCollection:do doesn't have to know whether
it is being passed a named or anonymous function and it will be easy
to convert to real anonymous functions in 3.1. The disadvantage is
that errors can be a little tricky to locate.