Tuples a first class feature, manu's new unary operator and named arguments

12345swordy alexanderheistermann at gmail.com
Fri May 8 20:38:00 UTC 2020


As I am working on the "Tuples first class feature" dip (will 
uploaded first draft soon), I noticed that if we would allow this 
in D:

fun((int x = 10, int y = 1, int z = 2)...);

Could this be used as a replacement for named arguments? It would 
address the readability problem certainly. However it doesn't 
address the default argument values that certain functions have. 
I.E.

void sub(int x, int y = -1, int z) { ... }

if that were the case why not allow tuples such that

sub((int x = 0, int z = 0)...) = sub(0, -1, 0)

It will attempted to map tuple variables to function argument 
based on the named values. Then I realize that it will ran into 
the same issue with name arguments by default as that when the 
function arguments name been changed it will break users code, so 
no dice there.

Any thoughts on this? Right now, my dip is nothing more than much 
needed syntax sugar for tuples.

-Alex


More information about the Digitalmars-d mailing list