Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1

Timon Gehr timon.gehr at gmx.ch
Sun Nov 20 22:08:19 UTC 2022


On 20.11.22 22:58, Timon Gehr wrote:
> On 20.11.22 22:32, Walter Bright wrote:
>>
>> But yes, it would be a (small) breaking change.
> 
> I really wouldn't want to run into this:
> 
> ```d
> enum Role{
>      guest,
>      member,
>      developer,
> }
> 
> void main(){
>      Role r;
>      writeln(r); // error
> }
> ```
> 
> Too messy for me, but up to you.

Actually, I think with the current implementation of writeln this will 
work (subject to break at any time), but not this:


```d
enum Role{
     guest,
     member,
     developer,
}

void main(){
     Role r;
     string s=to!string(r); // error
}
```

Not a big fan of making local variable names part of the public API.


More information about the Digitalmars-d mailing list