lua-users home
lua-l archive

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


Just playing around, how do you like these, all of the same grammar,
different cases:

(<= nil)

(<a,b> = a*b)

(<x,y> = x+y, x*y)

(<a,b> if a then = b else = 0 end)

(< if upvalue then print "yes" end)

and the nested case for
(<x> = (<y> = x +y))

as shortcuts for:

function() return nil end

function(a,b) return a*b end

function(x,y) return x+y, x*y end

function(a,b) if a then return b else return 0 end

function() if upvalue then print "yes" end  -- returns nil

and
function(x) return function(y) return x + y end end

On Tue, Nov 23, 2010 at 5:34 PM, Drake Wilson <drake@begriffli.ch> wrote:
> Quoth steve donovan <steve.j.donovan@gmail.com>, on 2010-11-23 18:22:20 +0200:
>> String lambdas to the rescue!
> [...]
>> The irritating thing is that 'hero' would have to be a global or at
>> least a field in the environment you use to compile the lambdas; they
>> cannot be _closures_.
>
> Which is dreadful, and even the parts that can be gotten right are
> easy to get wrong and easy to break.  Passing code around as strings
> like that is one of those constructions that moves invisible coin
> blocks into your path when you're not looking.  It's more befitting of
> Tcl or PHP than the clean (if dusty and cratered) surface of Lua.
>
> (My local token filter uses « » and $1, $2, … for short expr funs and
> their arguments, but I gather many people might not like the non-ASCII
> bit.  << and >> are synonymous.)
>
>> steve d.
>
>   ---> Drake Wilson
>
>