Thread overview
Passing _arguments into another variadic function
Apr 12, 2016
Satoshi
Apr 12, 2016
Adam D. Ruppe
April 12, 2016
Hello, I have a little problem with Variadic functions.

I have function like:

void perform(string method, ...) {
// here I want to call method findMethod with _argptr and _arguments

}

MethodDesc findMethod(string method, ...) {
// some lookup through the tables...
}


I know there are variadic templates, but I want to use this style of implementation.

Is it possible to pass varargs to another function or must I do it by asm?


Thanks for help :)
April 12, 2016
On 4/12/16 5:08 AM, Satoshi wrote:
> Hello, I have a little problem with Variadic functions.
>
> I have function like:
>
> void perform(string method, ...) {
> // here I want to call method findMethod with _argptr and _arguments
>
> }
>
> MethodDesc findMethod(string method, ...) {
> // some lookup through the tables...
> }
>
>
> I know there are variadic templates, but I want to use this style of
> implementation.
>
> Is it possible to pass varargs to another function or must I do it by asm?
>
>
> Thanks for help :)

Tango used to do this (probably still does). I don't remember the details, but yes, it is definitely possible.

-Steve
April 12, 2016
On Tuesday, 12 April 2016 at 09:08:06 UTC, Satoshi wrote:
> Is it possible to pass varargs to another function or must I do it by asm?


In C, you would make a version of the function that takes the va_list type (see, for example, vprintf).

I believe in D, you'd want to do the same thing. Make another version of your function, one does foo(...) and one does foo(void* argptr, TypeInfo[] argtypes) and to forward the (...) version to the other, you call foo(_argptr, _arguments), which holds the real implementation.