lua-users home
lua-l archive

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


On Fri, Dec 4, 2009 at 12:49 PM, David Kastrup <dak@gnu.org> wrote:
> But wouldn't it feel inconsistent to have a shorthand for
> function(x) return x*x end
> but not for
> function(x) if x>0 then return 1 else return 0 end end

|x| x > 0 and 1 or 0 ?  (Granted, and/or does read a bit funny, but
it's an idiom we know and why I don't miss ?:)

> Wouldn't maintaining that elegance require that you get expression
> shorthands for most control structures in use for "short functions"?

Francesco's intention was to express simple one-liners, usually
one-to-one 'classical' mathematical functions. Where something more
complicated is happening, then the short form isn't a good idea.