No we should not support enum types derived from strings
Adam D. Ruppe
destructionator at gmail.com
Fri May 7 16:30:26 UTC 2021
On Friday, 7 May 2021 at 15:51:39 UTC, Steven Schveighoffer wrote:
> But an enum with base string type can be passed as a string.
"Can be passed as a" is not the same as "is a". There's a
conversion involved.
For better or for worse, D templates do not participate in
conversion and we shouldn't pretend that they do. This is often
times very useful - you don't want to lose information in many
templates. But there's other times when that information doesn't
matter and it would be nice it you didn't have to think about
it....
...so maybe we should consider changing templates so they can
participate at the language level... it would be interesting if
the compiler did the conversions BEFORE instantiating any
template. Then it can reuse the instances more easily too. I
think it actually does for const params for example, but it could
do more.
> User: "OK, but when should I use representation? I already pass
> it around as a string and it works fine. Why can't phobos
> comprehend that, when the language has no problems with it?"
But the language DOES have problems with it for certain types of
functions. Phobos is trying to deny that reality.
More information about the Digitalmars-d
mailing list