DIP 1019--Named Arguments Lite--Final Review

drug drug2004 at bk.ru
Tue Aug 27 13:52:19 UTC 2019


27.08.2019 16:47, aliak пишет:
> On Monday, 26 August 2019 at 22:45:16 UTC, Walter Bright wrote:
> 
> 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.

That is rather simple logic - named arguments are defined by name, 
unnamed ones are defined by position starting from the last named 
argument, i.e. the first unnamed argument follows the last named one.


More information about the Digitalmars-d mailing list