lua-users home
lua-l archive

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

On Thu, Sep 14, 2006 at 12:15:41PM -0700, Mark Hamburg wrote:
> A 5.2 request: It would be nice to have a mechanism/idiom to replace the
>     x or y
> idiom in cases where we want y if x is nil but not if x is false.

How about the ternary operator?

  x ~= nil ? x : y

I bet you could do the above with the token filter ;-)

Or how about everything becomes an expression:

  tobeornottobe = if x == "B" then "be" else "be not" end

I like that in lua functions are first class objects. Very nice. But I
miss that control structures are not expressions, and that I can't break
to an arbitrary label.