DIP proposal: Enum parameters

TheGag96 thegag96 at gmail.com
Tue Sep 27 14:39:58 UTC 2022


On Friday, 23 September 2022 at 15:41:21 UTC, Quirin Schroll 
wrote:
> Read the draft here: 
> https://github.com/Bolpat/DIPs/blob/EnumParameters/DIPs/1NNN-QFS.md
>
> Feedback is welcome.

So my first thought seeing this was that `enum` parameters would 
bind to compile-time constants but don't incur extra codegen for 
each value passed in, and `auto enum`, when used once at least, 
would implicitly generate exactly two copies. But given this, I 
don't think that's what you're saying:

> In the function body (including contracts and constraints), an 
> `enum` parameter’s value is a compile-time constant as if it 
> were template value parameter. The same is true for `this` in 
> an `enum` non-`static` member function body. The difference 
> between `enum` parameters and template value parameters is only 
> in calling syntax: `f!ct_value(args)` versus `f(ct_value, 
> args)`.

So the DIP exists purely to introduce a more unified calling 
syntax?


More information about the Digitalmars-d mailing list