No we should not support enum types derived from strings

deadalnix deadalnix at gmail.com
Tue May 11 16:26:16 UTC 2021


On Tuesday, 11 May 2021 at 15:33:45 UTC, Andrei Alexandrescu 
wrote:
> If we move the goalposts we can with certain ease create the 
> illusion that a lot of things are possible and even easy.
>
> [...]
>
> At any rate, we decided this would complicate everything in 
> Phobos way too much (and I think that was a correct prediction) 
> so we chose to have popFront() mutate the current range.

I don't think that any of what you wrote is incorrect, and these 
are even reasonable tradeofs as far as I can tell.

I however would like to remind where this whole thing starts from:

format!SomeEnumString(...) is expected to work for users.

Not that SomeEnumString is a full fledged range or anything, 
simply that you can pass is down to phobos, or anything else for 
that matter, in place where a string is expected.

This is reasonable expectation.

It is also a reasonable expectation that this shouldn't require a 
ton of scaffolding to work, in phobos or elsewhere.

Therefore, the fact that phobos required scaffolding to make this 
work is indicative that there is a deeper problem. Focusing on 
finding what that deeper problem is and fixing it seems like a 
healthier path forward than simply pretending there is no problem 
and pushing it all on the users.

I this case, it was noted here ( 
https://forum.dlang.org/post/umndraexmrxiyrmfpcyo@forum.dlang.org 
) that the root cause of the problem might be that there is a 
conflation between the container and the range. I think this is a 
reasonable hypothesis. Having two things trying to do one thing 
is a very typical source of such problems.


More information about the Digitalmars-d mailing list