debug a reserved keyword (even for enums?)

Kapendev alexandroskapretsos at gmail.com
Sat Apr 11 23:27:14 UTC 2026


On Saturday, 11 April 2026 at 09:33:34 UTC, libxmoc wrote:
> The fundamental issue isn't whether non-contextual keywords are 
> easier to parse, it's that D already has a mechanism to 
> disambiguate: the dot operator. loggingLevel.debug, 
> Align.align, and SemVer.version are all unambiguous to both the 
> parser and the reader. The token following a dot is already in 
> a different lexical context.
>
> There's precedent for this in other languages. Rust allows 
> self.as and match.as because keywords after . are unambiguous. 
> Even C#—hardly a radical language—has contextual keywords in 
> specific positions.
>
> The "trailing underscore" convention is a concession that keeps 
> accumulating.
>
> debug_, version_, align_, function_, immutable_... at what 
> point do we acknowledge that the cure (universal keyword 
> reservation) is worse than the disease (contextual parsing 
> complexity)?
>
> Editions exist precisely to make breaking improvements like 
> this possible without fragmenting the ecosystem.
>
> Let's do it.

Breaking things just to be able to use `align` or `debug` as a 
variable or enum name is not worth it. The solution: find better 
names.

- align: alignment
- debug: debugMode

No language change needed and is backwards compatible. Can't 
comment about contextual keywords.


More information about the Digitalmars-d mailing list