[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Scheme's "delay" function in plain Lua?
- From: steve donovan <steve.j.donovan@...>
- Date: Sun, 31 Oct 2010 20:22:29 +0200
On Sun, Oct 31, 2010 at 6:39 PM, Johnson Lin <email@example.com> wrote:
> There's still some possibility to write simply lazy( x(x) ) without
> the real function being evaluated,
That's precisely one of the goodies that Geoff has in Rima.
I came up with a similar thing when working on functional idioms for
Penlight, inspired by the Boost::lambda library.
It does work, yes, and the result is efficient because these
expressions are compiled into Lua bytecode (via their string
representation). Although it's not so easy to cache the result as
with string lambdas. (The cool thing about this representation is that
symbolic algebra becomes possible and in fact pretty straightforward.)
I remain in mourning about the fact that |x| x*(x+1) will never be
found in mainline Lua, but gotta move on... with the token-filter
patch, the form \x(x*(x+1)) is easy to implement, but I rather doubt
as well that any form of the token-filter patch will become canonical