[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing expression as a parameter
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 8 Jan 2013 09:34:18 +0200
On Tue, Jan 8, 2013 at 9:21 AM, Ivo Beltchev <ivo@ibeltchev.com> wrote:
> #3 gives me direct control when and how often to evaluate the function, but
> I’m not sure how efficient it is, especially if local variables are used
I'd wager that it's not slower than #2 (and a lot faster than #1) if
the payload is non-trivial.
Anonymous functions in Lua are very cool, pity about the need to use
three keywords. If it's for an in-house project, maybe use the short
lambda patch? That is, |x| x^2 is fully equivalent to function(x)
return x^2 end.
Alternatively, macro preprocessing. E.g. in Luamacro you can implement
wait(GetPlayerHealth(index)<50) easily, and the short lambda syntax is
\x(x^2)
(Yes, I would like this for Christmas, any Christmas, but people get
surprisingly excited about this)