debug a reserved keyword (even for enums?)

Dukc ajieskola at gmail.com
Wed Apr 15 16:06:31 UTC 2026


On Friday, 10 April 2026 at 22:37:54 UTC, Katastic wrote:
> Hello all, it's been awhile. I have a question. Does it make 
> 'sense' that debug is a reserved keyword even when its inside 
> an enum?

Yes I think.

D is designed so that it can be lexed separately from parsing, 
and parsed separately from compiling. Contextless keywords are 
needed for that feature to work.

`debug` needs to be a keyword, because it's needed to recognise 
code like `debug import std.stdio;`. If `debug` was considered 
just an identifier like any other, this wouldn't parse any more 
than `someName import std.stdio;`.

Now, there are some unnecessary keywords in D. The type names 
like `float`, `dchar` and `int` could be removed from keyword 
list as far as I see, since anywhere they can be used, an 
arbitrary type could be used in their place. They could be 
considered predefined types (just like `string`, `size_t` or 
`Throwable` for instance) with a normal non-keyword names. But 
`debug` is not among those reduntant keywords.


More information about the Digitalmars-d mailing list