3 ms·
While I use `const` for a lot of my variables that I don't want to change it feels super-super wrong.
by romanovcode 9y ago
While I use `const` for a lot of my variables that I don't want to change it feels super-super wrong.
- savanaly 9y agoWhat feels wrong about it?
- aaron-lebo 9y agoIt's an incredibly verbose way to do what you'd prefer to be the default. val or con would have been better.
- BurningFrog 9y agoYeah, those 60% extra characters do bother me. And the uneven indentation. I know some/most people don't care. I can't be one of them. Maybe we'll get `val` in ES9.
- simonbw 9y agoIs there really much of a difference between "const" and "con"? I get that one is 66% longer than the other, but does it actually affect the readability of the code or the amount of time it takes to write it?
- kazinator 9y agoCan't we compromise half way? How about cons! /whistle .../
- WorldMaker 9y agoGoing way back to ancient Lisps `let` has been the const declaration in a lot of programming languages. It's too bad ES2015 decided to use `let` for `var`/`val`, because `let` should have been const. That said, I've come to terms with const, even if I find I accidentally use let sometimes from time spent in Lisp and F#.
- kazinator 9y agolet is not a "const declaration" in most major dialects of Lisp, current and historic. In Scheme, Common Lisp, ISLisp, Emacs Lisp and others, it introduces mutable bindings.
- WorldMaker 9y agoApologies, my Common Lisp is getting rusty.
- romanovcode 9y agoYou wouldn't declare your in-scope variables as `const` in C/C++/C#/Java wold you?
- clappski 9y agoIn C++ I always do, everything is 'const auto &' if it can be. C# const is different, it's more like C++ '#define'. Why wouldn't you always go for the most immuatable declaration? Even in C++, where you can have 'const int f(const int y) const;' it's still worth using even though you have to type it a few times.
- whipoodle 9y agoThey're not variables if they don't vary ;)