On Sun, 31 May 2015 09:43:50 -0400, Michel Fortin wrote: > How does it handle overloading? > > string test(bool a, string b="wow", string c="heh") {} > string test(bool a, string c="heh", bool d=true) {} > > test(a: true, c: "hi"); // ambiguous!
as for named calls argument order doesn't really matter (i.e. it tries to reorder first, and then doing match), it can't resolve this. > The irony of this example is that without argument names (or more > precisely without reordering), there'd be no ambiguity here. yes. but i'm not sure that i want such resolving. but it's fairly easy to do: just try the original order first (as missing arg means "reordering" too), and only if there were no hits, try to reorder. little more code, though, for a feature i'm not sure i want. >> and this: >> void test(A...) (A a) { >> import std.stdio; >> foreach (auto t; a) writeln(t); >> } >> >> void main () { >> test(x: 33.3, z: 44.4, a: 9999, 7777, d:"Yehaw"); >> } > > For that to be really useful the argument names should be part of the > "A" type so you can forward them to another function and it still works. yes, i'm eventually planning to do that. inside the frontend they are NamedArgExp instances, so the information is here (althru they eventually lowered to UnaExp). adding traits to ask for name and using that without lowering to forward calls are the things in my TODO (along with the trait to strip name info). note that i done the patch in one day, so it's neither complete nor deeply tested. i simply tried to see if i can do that with minimal changes to frontend. and then i found that it's fairly easy. ;-) that's why i didn't made the patch public yet -- it's not really polished, and it's not really tested.
signature.asc
Description: PGP signature