News for hackers. Stuff that matters.
Re:John Carmack on Mutable Variables by Thorrez on Friday October 31, 2025 @08:15AM (#45771189)
"const" means something can't be changed. "mutable" means it can be changed.

You don't need both a "const" keyword and a "mutable" keyword in a programming language. You only need 1 of the keywords, because the other can be the default. munchler is saying the "const" keyword shouldn't exist, and instead all variables should be constant by default, and we should have a "mutable" keyword to mark variables as mutable.

As opposed to how C++ works today, where there is no "mutable" keyword, variables are mutable by default, and we use a "const" keyword to mark them constant.

Re:John Carmack on Mutable Variables by alcover on Friday October 31, 2025 @09:07AM (#45771571)
> you don't need both a "const" keyword and a "mutable" keyword

What if the lang has pointers? How express read-only?

Re:John Carmack on Mutable Variables by skeezyjefferson on Friday October 31, 2025 @11:28AM (#45773144)
compiler flags with line and column number seems like the easiest way
Re:John Carmack on Mutable Variables by Thorrez on Saturday November 01, 2025 @09:09AM (#45781369)
You can make everything read-only by default, and if you need non-read-only, you use "mutable".
Re:John Carmack on Mutable Variables by alcover on Saturday November 01, 2025 @03:16PM (#45784475)
You need two keywords. One for assignability and one for writability :

    const ptr;  // can't reassign, can't write-through (if r/o by default)
    const mut ptr;  // can write