variadic function: passing args

pragma pragma_member at pathlink.com
Thu Jul 6 16:14:06 PDT 2006


In article <e8jemv$2pfh$1 at digitaldaemon.com>, Ivan Senji says...
>
>Nice idea, IMO the compiler should do this for us, but it would be even
>nicer if we could do something like:
>
>blah = foo(...[0..5]); //Pass to foo only the first five arguments

I agree, although I don't like the idea of using "..." explicitly as an
identifier.  I'd rather see a variation of the "named vararg" syntax like so:

void foo(args ...){
writefln("hello world",args);
}

The only problem with the above case is: what type does 'args' actually have (or
in Ivan's example, what type does '...' have)?  

It could be considered an error to use the "vararg expression" in any context
other than as a function argument or parameter, but I can't help but think that
it would open up a whole world of expressions if it were a proper type unto
itself.

- EricAnderton at yahoo



More information about the Digitalmars-d mailing list