www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Variadic Functions

reply "Miguel Ferreira Simões" <Kobold netcabo.pt> writes:
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 
Jan 16 2005
parent reply "Regan Heath" <regan netwin.co.nz> writes:
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
Jan 16 2005
next sibling parent reply "Matthew" <admin.hat stlsoft.dot.org> writes:
"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
Jan 26 2005
parent pragma <pragma_member pathlink.com> writes:
"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
Jan 27 2005
prev sibling parent reply "Carlos Santander B." <csantander619 gmail.com> writes:
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
Jan 31 2005
parent =?UTF-8?B?QW5kZXJzIEYgQmrDtnJrbHVuZA==?= <afb algonet.se> writes:
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
Feb 03 2005