How to send variadic arguments

Zarathustra adam.chrapkowski at gmail.com
Mon Aug 25 08:08:58 PDT 2008


Steven Schveighoffer Wrote:

> The way it is done in Tango is to put the implementation in a function which 
> takes the _argptr and _arguments as parameters.  Then the actual variadic 
> function is just a wrapper.  If you want to chain another variadic function 
> to it, just pass the _argptr and _arguments.
> 
> Passing the argptr and arguments directly really should be a compiler 
> supported thing, as this is all you are doing anyways.  Similar to how you 
> can call opX directly.
> 
> -Steve 
> 
> 
Reply to Steve:

Do you mean something like that?

import tango.io.Stdout;
void func(char[] o_char, ...){  
  Stdout(o_char, _arguments, _argptr);
}

public static int 
main(){
  int l_result = 0;
  try{
    Stdout("smile", 2, 3, 4).newline;
    func("smile", 2, 3, 4);
  }
  catch(Object o){
    l_result = 1;
    Cout(o.toString);
  }
  return l_result;
}

## result:
smile, 2, 3, 4
smile, [int, int, int], 12fe58



More information about the Digitalmars-d-learn mailing list