DIP 1019--Named Arguments Lite--Final Review

aliak something at something.com
Tue Aug 27 13:47:49 UTC 2019


On Monday, 26 August 2019 at 22:45:16 UTC, Walter Bright wrote:
> On 8/26/2019 7:47 AM, Kagamin wrote:
>> struct S { int a, b, c, d = 7; }
>> S w = { c:1, a:1, 3 };
>> 
>> I don't even know if this result is contrived. Maybe it's 
>> trivial?
>
> It initializes to:
>
>     c = 1
>     a = 1
>     b = 3
>     d = 7

So just to test out what people would say, I went around my team 
with this (individually, they didn't hear each other)

struct S { int a = 1, b = 2, c = 3, d = 4; }

void main() {
     S w = { d: 9, a: 9, 9 };
     writeln(w);
}

The answers:

1. a 9, d: 9,... b...2? wait no .... what? Ok I don't know.
2. ambiguous? compile error! why would this be allowed?
3. does the last 9 set all the unset vars??
4. Can't tell, but the first highest non set address?
5. compilation error
6. What is this. What is the usefulness of this. Nothing happens. 
It's bad. It should crash. I hate life.
7. this can't compile. If it does I would assume it's thrown away?
8. should crash?

Please don't allow the same logic to go in to named arguments.


More information about the Digitalmars-d mailing list