Never will I understand ternary operators. As soon as you introduce it, some chuckle heads want to use them everywhere. Worse if the syntax allows nested ternarys. I guess it keeps the language open for code golfing, but it otherwise seems like redundant syntax that at best saves a few characters.
That’s why “if” should just be an expression
LuaJIT 3.0 proposed syntax extensions
41–50 of 170 posts
Re: LuaJIT 3.0 proposed syntax extensions
#42So is LuaJIT resuming active development after a decade or so of only maintenance? Great! A lot of these changes make sense (although some of them are a bit too TIMTOWTDI for my taste) - but perhaps LuaJIT 3 would benefit from a change of name as well? Certainly with all these changes, it would be more like a separate language than merely a JIT-compiled version of Lua.
>TIMTOWTDI What on earth is this supposed to mean?
Re: LuaJIT 3.0 proposed syntax extensions
#43Re: LuaJIT 3.0 proposed syntax extensions
#44That's just one example of so many more. I get that lua occupies a useful niche with its focus on embedded systems, but lua is not really a well-designed language in general. JavaScript has a similar problem.
Re: LuaJIT 3.0 proposed syntax extensions
#45Never will I understand ternary operators. As soon as you introduce it, some chuckle heads want to use them everywhere. Worse if the syntax allows nested ternarys. I guess it keeps the language open for code golfing, but it otherwise seems like redundant syntax that at best saves a few characters.
I guess for the JS case it makes sense to be able to shave a few characters for file shrinking purposes, but generally I'm more biased to code clarity and "self-explainability"
Re: LuaJIT 3.0 proposed syntax extensions
#46I would love to see all of these come to LuaJIT (and love2d to support the new version too). It’s nice that Lua is simple, the syntax changes should hopefully make Lua code even simpler to read too
> It’s nice that Lua is simple, the syntax changes should hopefully make Lua code even simpler to read too But which Lua? Lua as implemented by LuaJIT is a fork of the language at this point. It's not fully compatible with PUC Lua (the reference implementation) and LuaJIT does not support features from the latest Lua version.
Re: LuaJIT 3.0 proposed syntax extensions
#47Earlier quoted context omitted.
I love the ternary operator as much as anyone. But dang if it doesn't get hard to read when there is are a few, nested even. Does that operator compile to faster assembly that if I make the same logic with verbose `if` logic? Is that a language specific outcome?
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.
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
#48What are some pragmatic embedded scripting languages of choice these days if one has to consider: 1) Ease of learning, ideally minimal deviant behaviour (eg i consider lua tables to be a new concept in itself) 2) Reasonably fast. Not as much as lua jit but even half would be good enough 3) Mature 4) Has Rust bindings
Re: LuaJIT 3.0 proposed syntax extensions
#49Why though? What does changing `and` to `&&` actually achieve? Were people confused?
Changing the syntax seems very surface level. It's not actually fixing any problems, just making Lua no longer look like Lua. It's not going to help anyone write/learn Lua. It will make everything more complicated as there are now two ways to do everything.
This feels like adding braces to Python because you don't like indenting your code.