4 ms·
Why can't it add keywords? Adding a new keyword doesn't break backward compatibility. It breaks "forward compatibility."
by kodra 3y ago
Why can't it add keywords? Adding a new keyword doesn't break backward compatibility. It breaks "forward compatibility."
- Dylan16807 3y agoOld code becoming a compiler error sound like a backwards compatibility issue to me.
- kodra 3y agoI guess it's a terminology thing. As someone from a C# background, not all keywords are reserved words. Only new reserved words break backward compatibility. C# has added some keywords (record, and, or) without breaking backwards compatibility.
- tptacek 3y agoNew keywords are like the textbook example of a backwards compatibility problem. It's probably why C overloads "static" so many different ways.
- kodra 3y agoYou mean new reserved words? For example, I'm quite sure when C# added "record" it didn't break backward compatibility, as old code that uses "record" as a variable name still compiles.
- tptacek 3y agoGo 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.
- pcwalton 3y agoYou 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 "{".