Using std.conv.to with enum that is based on string type

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 19 12:46:04 PDT 2014


Uranuz:

> So as I think there are 2 options.

There is a third option, that is to add a little extra function 
that does what you want.


> First is keep it al *as is*. In this case I propose to improve 
> documentation about it that in case of conversion of enums into 
> string types and vice versa we actualy converting *identifiers* 
> but not underlying values.

Improving the documentation is good.


> The second option is to change it to conversions between 
> underlying values. In this case we need to evaluate how much 
> code will be broken and take some measures to warn developers 
> about these changes.

Time ago I opened an enhancement request that essentially asks 
this, and it was closed down. So I think this is not an option. 
(And now I have code that relies on the current behavour).

Bye,
bearophile


More information about the Digitalmars-d mailing list