www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Passing _arguments into another variadic function

reply Satoshi <satoshi gshost.eu> writes:
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 :)
Apr 12 2016
next sibling parent Steven Schveighoffer <schveiguy yahoo.com> writes:
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
Apr 12 2016
prev sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
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.
Apr 12 2016