Pass _arguments to next method?

Steven Schveighoffer schveiguy at yahoo.com
Fri Jul 4 06:31:24 PDT 2008


"Benjamin Schulte" <Aldoric at gmx.de> wrote in message 
news:g4kpm3$16km$1 at digitalmars.com...
> Hi!
>
> For example, we have the following methods: (Just example - might not be 
> useful ;P)
> void calc_sum( ... ) { /* do something */ }
> void calc_dif( ... ) { /* do something */ }
> void calc( int what, ... ) {
>  switch( what ) {
>    case 0: calc_sum( /* here is the problem */ ); break;
>    case 1: calc_dif( /* here is the problem */ ); break;
>  }
> }
>
> How can I pass the _arguments to the next called methods?
>
> Thanks in advance :)

The only way I have seen it done (in Tango), is to have a helper function 
that does the real work which takes the vararg information as parameters.

For instance:

void real_calc_sum(TypeInfo[] arguments, ArgList args)
{ do the real calc sum here}

void calc_sum(...)
{
    real_calc_sum(_arguments, _argptr);
}

Then you can call real_calc_sum from your calc function, and calc_sum is 
callable outside calc as a variadic function.

-Steve 





More information about the Digitalmars-d mailing list