Luau is an extended version of lua. In fact, Roblox has used luau for some time already.
If you’ve learnt to code in lua there’s absolutely no difference other than some handy additions we didn’t get in the original lua. And those differences are way too small to call luau an entirely different language, or even engine.
You’re already using LuaU right now as you write your roblox code. I think you mean strict type checking instead, which likely won’t ever be forced; as it would break every existing game not using it.
local isCool = false
local realResult = (isCool and 'isCool is true!!!') or 'isCool is not true'
print(realResult) -- < this returns 'isCool is not true'
i would LOVE if you could simply do:
local isCool = false
local realResult = isCool ? 'isCool is true!!!' : 'isCool is not true'
print(realResult) -- < returns 'isCool is not true'
hear me out… what if we also added this so it also works + has a good appearance
I think that you have a good point, but Luau is already unique – why not add one thing that isn’t unique?
local result = if isCool then 'I am cool' else 'I am not cool'
can be shortened a good amount, into
local result = isCool ? 'I am Cool' || 'I am not cool'
It’s readable and although other languages use it, I think that it can be used in Luau as well to slightly reduce the developers’ time spent writing code.
Love the work! Are there any plans to add something akin to incrementing by 1 with both pre and post processing directives? An example to this would be ++numberValue(PreProcessing) and numberValue++(PostProcessing) This will help me out in sorting through numbers that I may not want to use in the current process that I’m trying to iterate through, allowing me to be a bit more flexible with how I design the methods I create.
I believe we’ve covered ++ before - we don’t have plans to add it. There’s many reasons as to why
not:
Pre- and post- forms are usually considered a mistake in language design, because the return value isn’t immediately obvious to readers unfamiliar with the arcane rules
Having an expression that modifies the variable results in complex order dependent evaluation and easy to make mistakes along the lines of process(foo++, foo) – this is also why our compound assignment operators are statements, not expressions
Adding a ++ without -- would leave a glaring symmetry gap in the language, but -- can not be added since it already means a comment
I guess that could make sense and honestly slipped over my head there. I come from a C++ background so it’s easy to get used to a certain way of codebase design. But love the work, the if-then-else is something that I instantly knew I’d start using. I’m a person who likes clean, minimal but effective code.
Now I won’t need to do
local value
if condition then value = value1 else value = value2 end
Makes those circumstances much more cleaner and I’m all for it
Curious as to why it wasn’t implemented exactly like Python. I think local a = b if c else d would make much more sense to read out loud, as well as the expression be shorter since there is no need for a then. But regardless, I’ll be using this.
The order of evaluation is wrong and parsing it is problematic.
local a = print(1) if print(2) or true else print(3)
-- 2 gets printed first!
local b = print(1) if print(2) or true then print(3) end
-- this is actually 2 statements
local b = print(1)
if print(2) or true then print(3) end
-- figuring out if 'if' is an if statement or if expression is complex
-- with this syntax