New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
final
as new keyword
#700
Comments
what would it do if the target isn't lua5.4? |
quoted from https://github.com/teal-language/tl/blob/master/docs/tutorial.md#const-variables
|
I have restrained myself from making purely cosmetic changes/additions to the "Lua parts of the language" so far, and I don't have immediate plans to change this. But if I were to do this, I'd probably just name it |
For an example (with a small module) of the tedious syntax of annotation, see |
I read the previous comments, 5.1 const can just throw an error if you do something dumb, const could be noice for functions too! Like if you want function(test: const number)
test = test + 1
end would throw an error like |
Lua 5.4 & Teal support the
<const>
annotation. That allows immutable variable.But for large use, the annotation syntax is ugly and too long.
My proposal is just a sugar syntax based on a new keyword
final
:final foo = something
-->local foo <const> = something
final fn() end
-->local fn <const> = function() end
The text was updated successfully, but these errors were encountered: