How to delegate varargs

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Nov 20 13:10:27 PST 2007


"Sean Kelly" <sean at f4.ca> wrote in message 
news:fhvhck$204d$5 at digitalmars.com...
> Tomas Lindquist Olsen wrote:
>> Frank Benoit wrote:
>>> How can I delegate the variadic argument list to another variadic
>>> argument function?
>>>
>>> e.g.
>>> void myWritef( char[] frm, ... ){
>>>   writefln( frm, ??? );
>>> }
>>>
>>> And how can I add or remove arguments to these varargs?
>>
>> You have to write a "wrapper" function that explicitly takes the hidden 
>> arguments. In the case of writefln, phobos provides OutputStream.writefx.
>
> Yup, and this stinks.  I don't suppose some language feature could be 
> provided for working around this?
>
>
> Sean

It would be nice if varargs were passed instead as a reference to an array 
that's built on the stack out of (typeinfo, value) pairs.  Problem with 
that, of course, is that each value can be a different size..

Tricky indeed. 





More information about the Digitalmars-d mailing list