DIP proposal: Enum parameters

Quirin Schroll qs.il.paperinik at gmail.com
Mon Sep 26 11:43:56 UTC 2022


On Monday, 26 September 2022 at 09:18:54 UTC, claptrap wrote:
> Using enum to mean "compile time" or "manifest constant" should 
> be depreciated in favour of a keyword that actually at least 
> vaguely relates to those meanings.

The value of that would be close to zero. At least in Phobos, 
`enum` is more often used to define a single value than an 
enumeration type.

With a new keyword, we’d need to deprecate `enum` or have both, 
also we’d have make sure the new keyword is dissimilar to 
identifiers currently used not to break code. On parameters, a 
compiler-recognized UDA, say `@comptime`, would be an 
alternative, but that cannot be trivially used instead of `enum` 
without special-casing it in the grammar. Inconsistency is worse 
than bad naming. Also, I don’t think that `enum` is actually a 
bad name. It has a specific meaning in D, but apart from that, 
it’s not that bad.

[Half Joking] Another option would be no keyword at all, but some 
kind of other token. But I guess no one prefers ``f()(^int x)`` 
or similar over ``f(enum int x)``.


More information about the Digitalmars-d mailing list