debug a reserved keyword (even for enums?)

libxmoc libxmoc at gmail.com
Sat Apr 11 09:34:32 UTC 2026


On Saturday, 11 April 2026 at 01:38:30 UTC, Jonathan M Davis 
wrote:

This is exactly the kind of friction that D editions should 
address.

I've been bitten by this twice recently: once designing a UI 
system where Align align; was illegal, and again a few months ago 
with SemVer version. Both times, the trailing underscore 
workaround felt like unnecessary concessions for perfectly 
unambiguous code.

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.



More information about the Digitalmars-d mailing list