lua-users home
lua-l archive

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


Hello, lua-users,

Attached patch is a ternary operator patch for Lua 5.1.4.  I made it but I am not confidence that this patch is correct.
Could someone review my patch and point out any defect to me?

A syntax of ternary op. is if/then/else, so it is like haskell.  You can write a code as following:

a = if x == y then good() else bad()

c = string.char(x + (if x < 10 then string.byte('0') else string.byte('A') - 10))

A priority of if/then/else operator is lowest.

Thank you,
Ryota Hirose

Attachment: lua-ifexpr.diff
Description: Binary data