[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Short Anonymous Functions
- From: Geoff Leyland <geoff_leyland@...>
- Date: Mon, 23 Mar 2009 17:31:44 +1300
I read the wiki page on Short Anonymous Functions ( http://lua-users.org/wiki/ShortAnonymousFunctions
), and noticed that there's nothing there that proposes the approach
that is (or at least was a few years ago) used in the Boost Lambda
Library: make special argument placeholder objects (say _1, _2 ..._N),
and overload the operators for these to return callable objects.
This means you can, for example:
for i = 1, 10 do
test(_1 + 100 + _2)
Does anyone have any comments on or interest in such an approach?
I've attached working proof-of-concept code that only handles
addition, but clearly you could do much more.
My interest is in writing a binding to Linear Program solvers (CLP in
the first instance) and I'm fiddling with nice ways of expressing
constraints. In this case you have variable placeholders rather than
argument placeholders, but it's pretty much the same.
Description: Binary data