www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - In-place struct initialization

reply test123 <test123 gmail.com> writes:
https://github.com/dlang/DIPs/pull/22
https://github.com/dlang/DIPs/pull/71


6 year passed, any idea when this will be done ?
May 02 2022
parent reply test123 <test123 gmail.com> writes:
On Tuesday, 3 May 2022 at 06:38:34 UTC, test123 wrote:
 https://github.com/dlang/DIPs/pull/22
 https://github.com/dlang/DIPs/pull/71


 6 year passed, any idea when this will be done ?
Wilzbach ask Andrei Alexandrescu to comment at this link: https://github.com/dlang/dmd/pull/8460#issuecomment-438920811 Almost 4 year passed and no comment yet. Maybe Andrei Alexandrescu has response on the form or other place, but he should has the courtesy to add comment to github too. 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.
May 02 2022
parent reply Salih Dincer <salihdb hotmail.com> writes:
On Tuesday, 3 May 2022 at 06:38:34 UTC, test123 wrote:
 https://github.com/dlang/DIPs/pull/22
 https://github.com/dlang/DIPs/pull/71


 6 year passed, any idea when this will be done ?
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 79
May 03 2022
parent reply test123 <test123 gmail.com> writes:
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 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.
May 03 2022
parent reply Paul Backus <snarwin gmail.com> writes:
On Tuesday, 3 May 2022 at 09:56:36 UTC, test123 wrote:
 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.
This will be covered by DIP 1030, "Named Arguments": https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md The DIP has already been accepted, and work is currently in-progress to implement it in the compiler. Once it is finished, you will be able to write code like the following: ```d Test(verbose: true) void doTest() { // ... } ```
May 03 2022
next sibling parent test123 <test123 gmail.com> writes:
On Tuesday, 3 May 2022 at 13:47:54 UTC, Paul Backus wrote:
 This will be covered by DIP 1030, "Named Arguments":

 https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md

 The DIP has already been accepted, and work is currently 
 in-progress to implement it in the compiler. Once it is 
 finished, you will be able to write code like the following:

 ```d
  Test(verbose: true)
 void doTest() {
     // ...
 }
 ```
This will work for most use case, if you add a verbose this __ctor to struct all struct. If D support In-place struct initialization , then the __ctor is no need for a lot case.
May 04 2022
prev sibling parent Salih Dincer <salihdb hotmail.com> writes:
On Tuesday, 3 May 2022 at 13:47:54 UTC, Paul Backus wrote:
 On Tuesday, 3 May 2022 at 09:56:36 UTC, test123 wrote:
 consider this code:

 ```d
 struct Test {
       string tag;
       string logger;
       bool profile;
       int verbose;
 }
 ```
```d Test test = { verbose = 100, tag = "default", logger = "files...", profile = true }; ``` Will this use case remain in effect? A lot of its useful! Thanks...
May 04 2022