NickL
NickL
MModular
Created by Henk-Jan Lebbink on 2/29/2024 in #questions
How to tell Mojo that something is intended to be constant?
There's obviously reconcilable points here in my opinion, which I hope the Mojo team considers. - 'let' was not a completely useless keyword to the old Mojo compiler because it was used to AUTO-enforce run-time variable immutability at compile-time (alias is not a replacement). - 'let' is a meaningless word ('const' would have been a clearer choice), but still, 'var' is already handling the complementary case so I'm glad they are cutting meaningless keywords from the language. - Immutable variables are important and helpful to reason through code that uses multithreaded or asynchronous processes. - There probably shouldn't be logic in a compiler to determine if the case used for each variable is all caps - I'm not totally opposed to these kinds of ideas, but really that's just asking for a unnecessarily slow compiler. Simple solution: - AUTO-enforce immutable variables by default unless explicitly tacked with 'var' in mojo functions Seems to me this solves reasonable concerns and provides a good default for making intentions clear in a simple way.
71 replies
MModular
Created by Henk-Jan Lebbink on 2/29/2024 in #questions
How to tell Mojo that something is intended to be constant?
If there are two types of variable modifiers that are fully complementary (mutable/immutable) then in theory you should only need one of them to express the intent (overriding the default)
71 replies