News for hackers. Stuff that matters.
Re:Constantly Confusing ‘const’ by gadrfgaesgysd on Tuesday September 08, 2015 @04:48PM (#10188138)
And people complain const in C is too complicated...
Re:Constantly Confusing ‘const’ by evincarofautumn on Tuesday September 08, 2015 @05:05PM (#10188204)
How do you mean? All this post is saying is that “const” in JavaScript is the same as “final” in Java—it lets you make immutable references, but not immutable objects. In C terms, you can express this:

    T *const x = ...;  // Immutable pointer to mutable T.
But not this:

    T const *x = ...;  // Mutable pointer to immutable T.
Even so, I don’t agree with the author’s argument that “const” is to be avoided. It does offer some protection against minor errors, which is not nothing.
Re:Constantly Confusing ‘const’ by _getify on Tuesday September 08, 2015 @05:21PM (#10188271)
I don't think my argument was to avoid `const`. I think my argument was to pick `const` at the end rather than at the beginning. I feel those are different arguments.
Re:Constantly Confusing ‘const’ by evincarofautumn on Tuesday September 08, 2015 @10:13PM (#10189302)
To be clear, “choose X last” does give the impression of “avoid X”, by which I don’t mean “don’t use X at all”. I disagree, but it’s a small matter; it’s not as if it would bother me to read your code.