Enum literals, good? bad? what do you think?

Dukc ajieskola at gmail.com
Thu Jul 22 03:21:06 UTC 2021


On Tuesday, 20 July 2021 at 15:50:49 UTC, russhy wrote:
> So what do you think? yay? nay? why not?

As mentioned by others, `enumVar = .memberName` is ambiguous with 
the module scope operator. If you want to pursue this, might I 
recommend `enumVar = "memberName"` instead? You still need no new 
syntax, and it could be implemented with value range propagation 
mechanics. This way:

If a `string`, `wstring` or `dstring` `str` that is known at 
compile time, is assigned to value of enumerated type `ET`, it is 
interpreted as assigning `mixin("ET." ~ str)` to the assignee 
value.


More information about the Digitalmars-d mailing list