This is awesome to see, really quite game-changing to be honest.
Now there’s no need to do any parameter type checking, which even with a function is a pain.
Will there be support for Roblox datatypes?
Also, the => syntax isn’t really my cuppa tea, if it was -> (like Rust) it’d be much nicer to use.
Also, as many people are mentioning not liking the syntax / thinking it’s too symbol based rather than keyword based: keep in mind that keywords aren’t free. Every keyword they add is an identifier no longer usable. It could end up making scripts harder to port if too many are added. (and yes, adding more would be necessary if you want it to make sense - for example, when specifying the return types of functions)
I do agree that some of the syntax could be more intuitive, but it really isn’t all that bad - I’m fine using it personally
I suspect since typeof() is actually a function, supporting custom types here would be a bad idea. Roblox will probably have to declare another type checking function, or maybe just accept that this breaks some stuff (I don’t even know if types are readable on run time).
workspace.ChildAdded:Connect(function(Object: Instance) => nil
end) -- Perfectly fine
However,
local x : Instance = workspace
x.ChildAdded:Connect(function(Object: Instance) => nil
end) -- W00 Argument count mismatch. Function takes 2 arguments but you passed 1
I’m guessing only primitives are currently fully supported?
Yeah, would need Rojo to support it as well as an extension to highlight .luau files. (Possibly in the future roblox could also release a language server for rojo users so we can get intellisense etc?)
I think I’ll need Rojo and syntax highlighting, and linting, to adapt typed Lua too. Typing is good, but my love of git as source control, as well as local files, as well as luacheck is just too good.
Although it wouldn’t take much to replace luacheck, compared to TypeScript’s validators, luacheck is quite disappointing. Hoping that this syntax parsing that Roblox is doing can be used for this sort of thing too–that would be super neat!
This is awesome! My C# appreciations can finally become true within Roblox Lua coding.
Jokes aside, could we please shorten boolean to bool? It’s kind of a standard on many object based languages since it is slightly shorter and faster to write. We’re still in time to fix that up… right?
My game’s compiler minifies variable names, and using as for variables can cause compatibility problems.
local as = function()
end
as()
:4: Expected '=>' when parsing function type, got <eof>
I fixed it by simply adding "as" to my compiler’s list of off-limit variable names, but my game’s live build started getting server errors when requiring that module yesterday out of the blue which is pretty serious. Lots of reports of players stuck at the loading screen.