lua-users home
lua-l archive

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


On 07/09/2013 22.07, slayer beast wrote:
> A ternary operator would be a nice addition to Lua 5.3 so we can stop
> using the and-or hack
> 
Well, I like the and/or idiom and I accept the term "hack" only because
it fails when "false/nil" comes into play, which is a lack of
orthogonality and a nasty pitfall (sometimes it still bites me). It is
the only case in which I miss a ternary operator.

Sometimes I wondered whether letting the if statement to be an
expression would solve anything (made up syntax, with new "let" keyword
meaning "this is the value of the statement"):

    a = if x > 0 then let "hello" else let "argh" end

but I'm not sure.

-- Lorenzo

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments