4 ms·
> This means that the vertical offset of names stays consistent This is also an argument for using keywords of the same length for introducing a variable and a
by pansa2 7y ago
> This means that the vertical offset of names stays consistent
This is also an argument for using keywords of the same length for introducing a variable and a constant. If that’s desirable, it rules out the obvious choices `var` and `const`.
Possibilities include `var` and `val`, which may be too similar-looking, and `var` and `let` - but are people used to (from JavaScript) `let` being mutable? Any other options?
- Someone 7y ago“Let” is mutable in Basic, too, but the part of the population that is used to that is shrinking. As to short, equal length options for ‘let’ and ‘val’: one could consider using punctuation. Forth uses colons instead of ‘fun’, and I think, in a concise language, one could get used to using, say, ‘!’ for immutable and ‘~’ for mutable. Unfortunately, they aren’t easy to type. An alternative could be to always assume immutability and only use ~ in the rare cases where one needs to mutate. So, a simple foo = 3 or, if one wants to simplify parsing: = foo 3 introduces a new immutable variable, and ~ foo = 3 or ~ foo 3 a mutable one. If we allow leaving out spaces: ~foo 3 that starts to look like using sigils to indicate mutable state. I think that might be a good option in a mostly immutable language. I think I would use Forth’s colon instead of ‘=‘. That would make ‘=‘ available for equality testing, allowing us to get rid of ‘==‘.