Allow designated initialization of struct

monkyyy crazymonkyyy at gmail.com
Fri Aug 30 19:19:18 UTC 2024


On Friday, 30 August 2024 at 16:02:38 UTC, ryuukk_ wrote:
> This should be allowed:
>
> ```D
> struct Data
> {
>     int a;
>     int b;
>     int c;
>     @disable this();
> }
>
> my_fun( Data { c: 1 } );
> ```

the debate is about nested stucts being spooky

```d
struct nullable(T){
   T get; alias get this;
   bool isnull=false;
   ...
}
struct runtime{
   this(int i){
     i.writeln;
}}
nullable!T somethingfailable(T)(T t){
   return nullable!T(isnull:true);
}
```
the compiler gets confused, whats a `somethingfailable.get`?

Im of the strong opinion that d should just let spookiness 
happen, if "ctfe this" fails to produce sane results, thats on 
the programmer, let it happen; but you "need" to "solve" the 
"problem" to suggest changes here.


More information about the dip.ideas mailing list