Thread overview
Variadic Functions
Jan 17, 2005
Regan Heath
Jan 27, 2005
Matthew
Jan 27, 2005
pragma
January 17, 2005
Can I have your opinion about this issue: http://www.digitalmars.com/d/archives/digitalmars/D/11254.html

In my humble opinion, I think we should be able to write:

void function1(...) {

}

void function2(...) {
    function1(...);
}

Is there any problem with this notation?

Thanks,

Miguel Ferreira Simoes


January 17, 2005
On Mon, 17 Jan 2005 01:31:09 -0000, Miguel Ferreira Simões <Kobold@netcabo.pt> wrote:
> Can I have your opinion about this issue:
> http://www.digitalmars.com/d/archives/digitalmars/D/11254.html
>
> In my humble opinion, I think we should be able to write:
>
> void function1(...) {
>
> }
>
> void function2(...) {
>     function1(...);
> }

or at the very least have some way of combining _arguments and _argptr back into a ...

void function1(...) {
}
void function2(...) {
  function1(vararg(_arguments,_argptr));
}

or as an even more powerful and generic solution some mechanism to allow you to pass all a functions arguments to another function, sort of like a nested function does.

> Is there any problem with this notation?

It doesn't seem ambiguous to me.

Regan
January 27, 2005
"Regan Heath" <regan@netwin.co.nz> wrote in message news:opskp5xzxa23k2f5@ally...
> On Mon, 17 Jan 2005 01:31:09 -0000, Miguel Ferreira Simões  <Kobold@netcabo.pt> wrote:
>> Can I have your opinion about this issue: http://www.digitalmars.com/d/archives/digitalmars/D/11254.html
>>
>> In my humble opinion, I think we should be able to write:
>>
>> void function1(...) {
>>
>> }
>>
>> void function2(...) {
>>     function1(...);
>> }
>
> or at the very least have some way of combining _arguments and _argptr  back into a ...
>
> void function1(...) {
> }
> void function2(...) {
>   function1(vararg(_arguments,_argptr));
> }
>
> or as an even more powerful and generic solution some mechanism to allow  you to pass all a functions arguments to another function, sort of like a  nested function does.

Third'ed



January 27, 2005
"Regan Heath" <regan@netwin.co.nz> wrote in message
> void function1(...) {
> }
> void function2(...) {
>   function1(vararg(_arguments,_argptr));
> }

Sexy.  Especially since it lets you build your own vararg lists from scratch. The only other way to accomplish *that* would be to write a shim.

This *definately* gets my vote.

- EricAnderton at yahoo
February 01, 2005
Regan Heath wrote:
> or at the very least have some way of combining _arguments and _argptr  back into a ...
> 
> void function1(...) {
> }
> void function2(...) {
>   function1(vararg(_arguments,_argptr));
> }
> 
> or as an even more powerful and generic solution some mechanism to allow  you to pass all a functions arguments to another function, sort of like a  nested function does.
> 
> Regan

FWIW, I agree with this (or any other way to accomplish it).

_______________________
Carlos Santander Bernal
February 03, 2005
Carlos Santander B. wrote:

>> or at the very least have some way of combining _arguments and _argptr  back into a ...
>>
>> void function1(...) {
>> }
>> void function2(...) {
>>   function1(vararg(_arguments,_argptr));
>> }
>>
>> or as an even more powerful and generic solution some mechanism to allow  you to pass all a functions arguments to another function, sort of like a  nested function does.
>>
>> Regan
> 
> FWIW, I agree with this (or any other way to accomplish it).

The only way to do it now is to use the workaround:

void helper(TypeInfo[] arguments, va_list argptr)
{
}

void function1(...) {
 helper(_arguments,_argptr);
}
void function2(...) {
 helper(_arguments,_argptr);
}

But that does not let you modify the argument list.
(e.g. if you want to add or remove any arguments)

Assuming that va_list is (void*) is *not* portable.
Using std.stdarg's va_arg is the way to get them out...

--anders