In-place struct initialization

test123 test123 at gmail.com
Tue May 3 09:56:36 UTC 2022


On Tuesday, 3 May 2022 at 08:28:32 UTC, Salih Dincer wrote:
>
> Do I need to know the name of the members in a struct? Isn't it 
> easier to use it unknowingly and directly?
>
> ```d
> assert(Extremes(1, 100).gaussSum == 5050);
> //auto t2 = Extremes(minor:12, major:99)
> Extremes(12, 99).gaussSum(3).writeln; // 1665
> ```
>
> On Tuesday, 3 May 2022 at 06:48:36 UTC, test123 wrote:
>> [...]
>> Maybe this is why D unpopular. Newbie come here and find the 
>> problem and solution, but D core team don't care to comment or 
>> merge it for 5 year.  This is sure to scare a lot of people 
>> away.
>
> I think you have to think well.  There may be another reason 
> for this.
>
> SDB at 79

consider this code:

```d
struct Test {
       string tag;
       string logger;
       bool profile;
       int verbose;
}


@Test({verbose:true)
void doTest(){

}

```


With in-place struct initialization you need pass all arguments.


Beside this, the work is not worth to merge can not be the reason 
to ignore the request to comment on github.



More information about the Digitalmars-d mailing list