Please change alias ReplaceArrayWithPointer = Flag!"replaceArrayWithPointer"

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 22 09:09:01 PST 2016


On 2016-01-21 20:31, Andrei Alexandrescu wrote:
> The correct idiom involving Flag is:
>
> * Use the name Flag!"frob" for the type of the flag
>
> * Use Yes.frob and No.frob for the flag values
>
> * Do NOT alias Flag!"frob" to a new name. This is unnecessary,
> unhelpful, and wasteful.
>
> Can somebody please change the respective code in std.experimental.ndslice?

Can we just implement a basic form of named parameters that remove the 
ugly workaround that Flag is.

void a(int x);
a(x: 3); // error, cannot be called with named parameters

void b(int x:);
b(3); // ok
b(x: 4); // ok

void c(int x:, int y:);
c(x: 3, y: 4); // ok
c(y: 4, x: 4); // error, named parameters out of order

The first error is to avoid making parameter names public API by 
default. The second error is to not change how overloading works.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list