Looks like LuaJIT is really going to fork away from Lua this time. After these changes, it won't be a compatible Lua 5.1 implementation anymore, it will be a new language. So shouldn't it have a new name?
Are there any rough estimates on popularity of lua implementations? At this point it feels lua means luajit
LuaJIT 3.0 proposed syntax extensions
31–40 of 170 posts
Re: LuaJIT 3.0 proposed syntax extensions
#32A comment https://github.com/LuaJIT/LuaJIT/issues/1475#issuecomment-47... > has already been made on the issue regarding the ternary operator, recommending `if x then y else z` over `x ? y : z`. This is exactly how it's done with if-then-else expressions in Luau https://luau.org/syntax/#if-then-else-expressions >, another language compatible with Lua, and makes it a ton easier to nest (especially with elseif) and I b…
The ternary operator is easy to nest if you put each clause on a separate line. Then it looks just like nested if-then-else.
Does that operator compile to faster assembly that if I make the same logic with verbose `if` logic? Is that a language specific outcome?
Re: LuaJIT 3.0 proposed syntax extensions
#33I’m confused I thought Mike Pall left luajit and Laurence Tratt took over as maintainer?
Edit: meaning he can come back anytime.
Re: LuaJIT 3.0 proposed syntax extensions
#34My ultimate goal was to support LuaJIT in Rust as well but this does not make it easier.
Re: LuaJIT 3.0 proposed syntax extensions
#35Earlier quoted context omitted.
That’s why “if” should just be an expression
This is the best answer in my opinion. Ternary is just sugar for an expressive if. LuaJIT seems to be focusing on adding new syntax though, maintainer might not be amenable to updating existing semantics.
Right now, `if` in expression position is just a syntax error ("unexpected symbol")
Re: LuaJIT 3.0 proposed syntax extensions
#36https://www.lua.org/versions.html#5.3
https://www.lua.org/manual/5.3/manual.html#3.4.2
Looks like LuaJIT is catching up, but calling these "syntax extensions" is confusing. Is the intent to hold LuaJIT fixed against some earlier Lua version (I guess 5.1) and adopt newer syntax piecemeal?
I welcome the compound assignment operators. Playdate's version of Lua also has that extension.
Re: LuaJIT 3.0 proposed syntax extensions
#37Earlier quoted context omitted.
The ternary operator is easy to nest if you put each clause on a separate line. Then it looks just like nested if-then-else.
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.Re: LuaJIT 3.0 proposed syntax extensions
#38What’s the Lua/LuaJIT story these days for bundling up all the scripts of an application into a single file? Is there a way to do the super convenient go-like thing?
Re: LuaJIT 3.0 proposed syntax extensions
#39Please don't, inscrutable bitwise operators are an accident of the past even in systems languages, let alone in a scripting language. I'm not against infix operators for bitwise operations, just please spell them out with keywords rather than giving them sigils. Likewise, going from `and` and `or` to `&&` and `||` would be a dispiriting regression. This is something that Zig got right.
Re: LuaJIT 3.0 proposed syntax extensions
#40What’s the Lua/LuaJIT story these days for bundling up all the scripts of an application into a single file? Is there a way to do the super convenient go-like thing?