I'd rather it use ?.() the . means getkey, () means expression using .(expr) should be the same as array[], throwing ? as a character should be very obvious what it does.
v <local const close>, v2 = io.open'file', false
g <global const> = 5
5.5 introduced global which makes better use of attributes as well. of course, I don't deny how great it would be to not type <> or local const since const would already imply a local str:gsub('%d+', (s){ tonumber(s)+1 })
> Named varargs: It may be nice, but there is no real reason to add this. If you wanted a name for your varargs you could do `local name = ...` or just use the `args` variable already available in every function. local name = ...
is local name = ({...})[1]
In order to actually do this you need to local name = table.pack(...)
If you will use a vararg, you will always have to do this, so why not just let it be handled in the parameter definition? its costless. AND lua5.5 already introduced this so it seems they liked it. for long,list,of,variables,here
in ageneratorhere(bigparameterhere)
do
end
and local x do
-- everything after is just here to define x
end
I'm still a little irked it works so well, the only alternative would be for the language to have labeled blocks. but that might be too terse x = a ? b : c # x is b, same as you would if a {x=b} else {x=c}
lua and/or a,b,c = true, 1, 2
x = a and b or c -- x is b
a,b,c = true, false, 2
x = a and b or c -- x is c
The or is dependent on its previous operand, so b will return false and skips to c, even if you meant for it to be b. you must use an if then else. However, you can have more than a ternary, if there is no need for short-circuit evaluation, as in, any of the operand is not a function CALL like c(), and you want to remain inside an expression, then you can do this instead x = select(a and 1 or 2, b, c)
table creation/selection x = ({false,2})[a and 1 or 2]
of course, doing something like local x; if a then x=b else x=c end
does not look so bad