Named variadic arguments

bearophile bearophileHUGS at lycos.com
Tue Jan 5 04:22:34 PST 2010


Coming from this question, named variadic arguments:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=18586

It's a possible way to implement something like this Python code:
def foo(x, y, **kwds):
  # here kwds is a dict of str:value

With another kind of typesafe variadic function:
void foo(int x, int y, Box[string] kwds ...) {}

foo(1, 2, z:10, w:30);
==>
In foo kwds == ["z":box(10), "w":box(30)];
(Variant or something else can be used instead of Box.)

Bye,
bearophile



More information about the Digitalmars-d mailing list