[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Short function definition syntax; thoughts on Lua
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 4 Dec 2009 14:17:20 +0200
On Fri, Dec 4, 2009 at 12:49 PM, David Kastrup <firstname.lastname@example.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.