Re:LuaJIT 3.0 proposed syntax extensions
by gnubison on Wednesday June 24, 2026 @11:01PM
(#48668303)
cond1 ? res1 :
cond2 ? res2 :
cond3 ? res3 :
or_else_res
If they are truly nested, then that is confusing. But if you have an if-else chain, then it can be quite readable.
Re:LuaJIT 3.0 proposed syntax extensions
by shevy-java on Wednesday June 24, 2026 @11:35PM
(#48668534)
I find that so much harder to read compared to if/else or case/when in ruby.
The ? is basically an attempt to use fewer if/else, at the cost of condensed if-else like structure. I always need to look at both parts after the ? whereas in a single if or elsif I don't. case/when in ruby is even better here e. g. regex check:
def foo(i)
case i
when /^cat/
handle_cats
when /^dog/
handle_dogs
(I ommitted the "end"s here to just focus on the conditional logic.)
Re:LuaJIT 3.0 proposed syntax extensions
by a-french-anon on Thursday June 25, 2026 @03:50AM
(#48670271)
Or they could just ask granddaddy for advice:
(cond (cond1 res1)
(cond2 res2)
(cond3 res3)
(t else_res))
=)
Re:LuaJIT 3.0 proposed syntax extensions
by matheusmoreira on Thursday June 25, 2026 @02:21PM
(#48677329)
An elegant weapon, for a more civilized age...
or
if cond1 then res1
else if cond2 then res2
else if cond3 then res3
else or_else_res
or if cond1 then res1
elif cond2 then res2
elif cond3 then res3
else or_else_res
what is most lua-like?
Does that operator compile to faster assembly that if I make the same logic with verbose `if` logic? Is that a language specific outcome?