How to delegate varargs

Chad J gamerChad at _spamIsBad_gmail.com
Tue Nov 20 16:45:51 PST 2007


Tomas Lindquist Olsen wrote:
> Tomas Lindquist Olsen wrote:
>>
>>  From a users point of view the only change to the D spec would be:
>>
>> At the end of the section "D-style Variadic Functions" append:
>>
>> <<<<<
>> The variadic arguments can be forwarded to another D-style variadic 
>> function by passing '...' as an argument. The forwarded arguments are 
>> bit-copied onto a new argument list.
>>
>>     void foo(...)
>>     {
>>         // do something
>>     }
>>     void bar(...)
>>     {
>>         foo(1, ..., 3.0);
>>     }
>>  >>>>>
>>
>> With this approach there is still no way to slice the argument list, 
>> for that a more high-level approach like the ones mentioned by Jarret 
>> in the "Variadic arguments and map" thread is probably needed.
> 
> Possibly also the section about "_argptr" should be changed to:
> 
> "These variadic functions have a special local variable declared for 
> them, _argptr, which is a void* pointer to the first of the variadic 
> arguments. To access the arguments, _argptr must be cast to a pointer to 
> the expected argument type. There is also a special local variable, 
> _argptrLength, which holds the length in bytes of the variadic argument 
> list"
> 
> This could however just be an implementation detail.

Why not just make it void[] _argdata?  It would save us some naming 
clutter.



More information about the Digitalmars-d mailing list