this is almost a workaround for the lack of named parameters

J notavail at notavailable.com
Sat Mar 23 01:20:17 PDT 2013


On Saturday, 23 March 2013 at 05:43:22 UTC, J wrote:
>>> auto s=callNamed!(fun,`x,y`)(10,20);
>
> Thanks, but this is a non-solution.
>
> The name must be next to the value ( x=10, y=20), so they it 
> will scale from 2 to 7 to 17 arguments and maintain readability.

For a use case, compare this call

reflectAndTranslate(2, 4, 5, 6, 1, 2, false, true, 15, false, 
true, false);


Quick, without looking at the docs, what does the false after 15 
do?

It's very hard to tell. Compare that to:


reflectAndTranslate(x=2, y=4, z=5,  offset=6, alpha=1, beta=2, 
invert=false, twist=true, colorBrush=15,  stideReduce=false, 
bindMatrix=true, slow=false);


It's self documenting.




More information about the Digitalmars-d mailing list