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

Nick Treleaven nick at geany.org
Sun Nov 27 16:14:09 UTC 2022


On Saturday, 26 November 2022 at 11:14:05 UTC, XavierAP wrote:
> But... Why then not not go one step further, and leave it up to 
> each one's private code to
>
>     alias _ = EType;
>
> when desired, and leave the language and backwards 
> compatibility alone?

Firstly I don't think it would break backwards compatibility in 
practice, see my reply to cc.

Secondly `alias` or `with` often does not help *at all* when you 
want type inference, and type inference already works with 
function literals:

```d
enum LongName
{
	a,b,c
}

LongName e;
void function(int) f;

void main()
{
	f = (int i){};
	f = (i){}; // infer parameter type

	e = LongName.a;
	e = $a; // infer parent type
}
```



More information about the Digitalmars-d mailing list