Flag proposal

so so at so.so
Mon Jun 13 18:36:01 PDT 2011


On Mon, 13 Jun 2011 20:19:15 +0300, bearophile <  
<bearophileHUGS at lycos.com> wrote:

> Andrei:
>
>> If we all get convinced that named parameters are worth it,
>
> I think this is not going to happen because some people (two?) don't  
> want this feature.

I think they worth it and it is the right time to talk extensively why  
people think they don't.
And reasoning should not be about its failure or success in another  
language, we better have our own rules.

IMO named arguments in D at least should do:

- Reordering (since we got default parameters, even better)

- It is enabled only if we have access to the function declaration.

- In a function call we either use named arguments for all the non-default  
arguments or call it with the usual syntax. No hybrid stuff, no confusion.

   fun(int a, int b, int c=3)

   fun(1, 2, 3) // fine - current
   fun(1, 2) // fine - current

   fun(a:1, b:3, c:5) // fine
   fun(a:1, b:3) // fine
   fun(b:1, c:3, a:5) // fine
   fun(b:1, a:3) // fine
   fun(b:1) // error
   fun(c:1) // error
   fun(2, b:1) // error
   fun(2, c:1) // error
   fun(2, c:2, 3) // error

Thanks.


More information about the Digitalmars-d mailing list