DIP proposal: Enum parameters

Paul Backus snarwin at gmail.com
Fri Sep 23 17:54:49 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.

Some thoughts.

* Does this need `__traits(isEnum)` (like `__traits(isRef)`) for 
working with `auto enum` parameters?

* Sometimes library authors prefer to have a parameter passed at 
runtime even when it *could* be passed at compile time, to avoid 
template bloat. So for use cases like `format` and `regex`, this 
proposal is not a clear win.

* A significant chunk of the proposed use-cases could also be 
addressed by adding `opStaticIndex`. Probably worth mentioning in 
the "Alternatives" section.

* Incompatibility with other parameter storage classes is a 
design smell. Ideally, we would like our language features to be 
orthogonal and work together with each other.

* Similarity to `ref` is also a design smell. `ref` is badly 
designed, and things like `auto ref` and `core.lifetime.forward` 
exist entirely to work around its deficiencies. We should avoid 
making the same mistake twice.

Overall, my impression is slightly negative. I can see situations 
where this would be useful, but I'm not convinced it's useful 
*enough* to justify the language-complexity and maintenance costs.


More information about the Digitalmars-d mailing list