News for hackers. Stuff that matters.
Re:Backward Compatibility, Go 1.21, and Go 2 by tptacek on Monday August 14, 2023 @01:37PM (#37123973)
New keywords are like the textbook example of a backwards compatibility problem. It's probably why C overloads "static" so many different ways.
Re:Backward Compatibility, Go 1.21, and Go 2 by kodra on Monday August 14, 2023 @01:40PM (#37124017)
You mean new reserved words? For example, I'm quite sure when C# added "record" it doesn't break backward compatibility, as old code that uses "record" as a variable name still compiles.
Re:Backward Compatibility, Go 1.21, and Go 2 by tptacek on Monday August 14, 2023 @01:59PM (#37124281)
Go has made changes like that by adding new predeclared identifiers ("any" is an example, I think?) but there's a distinction between predeclared identifiers and keywords.
Re:Backward Compatibility, Go 1.21, and Go 2 by pcwalton on Monday August 14, 2023 @04:06PM (#37126137)
You can sort of add new keywords backwards-compatibly using a trick called "contextual keywords": you require that they be placed in a syntactic position in which no identifier could legally go, and you maintain them as legal identifiers for compatibility. C++ used this trick to introduce "final" and "override" by moving them before the opening "{".