lua-users home
lua-l archive

RE: Syntactic sugar for function parameters

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


Robert Raschke wrote:
> > dropping () for function calls cannot work:
> > 
> > myprint = print
> > 
> 
> I think it was meant as in "if there's no parens after the 
> function take the next thing as the sole argument", like:
> 
> a_string = "foobar"
> print a_string
> 
> or
> 
> twice = function (x) return function(y) return x(x(y)) end 
> end double = function (x) return x + x end print (twice double 42)
Maybe it's time to introduce a space operator. That way the expression:
 print a_string
would turn into a call to some metamethod:
 function __space(a, b)
 return a(b)
 end
Maybe not :-)

AltStyle によって変換されたページ (->オリジナル) /