This should be allowed:
struct Data
{
    int a;
    int b;
    int c;
    @disable this();
}
my_fun( Data { c: 1 } );
| Thread overview | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 
 | 
| August 30, 2024Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| This should be allowed:  | ||||
| August 30, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to ryuukk_ | And in a perfect world:  | |||
| August 30, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to ryuukk_ | On Friday, 30 August 2024 at 16:02:38 UTC, ryuukk_ wrote:> This should be allowed: the debate is about nested stucts being spooky the compiler gets confused, whats a  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. | |||
| August 30, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to ryuukk_ | On Friday, 30 August 2024 at 16:02:38 UTC, ryuukk_ wrote:> This should be allowed: I'm not understanding the  Without that, this works: I tried making Data also have a ctor with all defaults, but it doesn't like that. -Steve | |||
| August 31, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Steven Schveighoffer | On Friday, 30 August 2024 at 19:37:22 UTC, Steven Schveighoffer wrote:> On Friday, 30 August 2024 at 16:02:38 UTC, ryuukk_ wrote:> This should be allowed: I'm not understanding the  Without that, this works: I tried making Data also have a ctor with all defaults, but it doesn't like that. -Steve brackets vs parenthesis, no ctor it's popular among C and newest languages (the irony), data first D lags behind, as usual  | |||
| September 12, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to ryuukk_ | Today i tried this: it refuses to compile: D worse than C with these stupid RAII, give me proper way to initialize a struct instead of giving me a broken constructor i'm not even using | |||
| September 12, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to ryuukk_ | On Thursday, 12 September 2024 at 12:14:17 UTC, ryuukk_ wrote:> Today i tried this: What did you expect to initializing an array of 8 elements with 1 value? all the same? | |||
| September 12, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Sergey | On Thursday, 12 September 2024 at 13:10:09 UTC, Sergey wrote:> On Thursday, 12 September 2024 at 12:14:17 UTC, ryuukk_ wrote:> Today i tried this: What did you expect to initializing an array of 8 elements with 1 value? all the same? What did i expect?.. right i expect to switch language as soon as i find an alternative Besides Test[8] test = Test.init; // <- works Data data = { test: Test.init }; // <- works char[256] path = "/dev/null"; // <- works Again, what do YOU expect? D people still don't understand why the language is not more popular and why people leave after they play with it I grew tired of trying to explain people how shitty things are for so long, wake up please | |||
| September 12, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to Sergey | >  add(Data(Test(1).repeat(8).array.to!(Test[8]))); I'm not sure if you are joking or not, i'll pretend this was a mistake of yours | |||
| September 12, 2024Re: Allow designated initialization of struct | ||||
|---|---|---|---|---|
| 
 | ||||
| Posted in reply to ryuukk_ | On Thursday, 12 September 2024 at 13:46:55 UTC, ryuukk_ wrote:> Again, what do YOU expect? D people still don't understand why the language is not more popular and why people leave after they play with it I grew tired of trying to explain people how shitty things are for so long, wake up please I see now what you want. Wasnt clear for me from the first look. | |||