www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Variadic arguments transmission

reply Victor Nakoryakov <nail-mail mail.ru> writes:
Hi all.

What is the easiest way to transmit variadic arguments to function with 
variadic arguments? E.g.

void foo(...)
{
	// some code
	// bla bla bla

	writef( ??? );	// here I want to transmit arguments of
			// `foo` without any changes.
}


-- 
Victor (aka nail) Nakoryakov
nail-mail<at>mail<dot>ru

Krasnoznamensk, Moscow, Russia
Aug 01 2005
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Victor Nakoryakov" <nail-mail mail.ru> wrote in message 
news:dcl06d$2e4o$1 digitaldaemon.com...
 Hi all.

 What is the easiest way to transmit variadic arguments to function with 
 variadic arguments? E.g.

 void foo(...)
 {
 // some code
 // bla bla bla

 writef( ??? ); // here I want to transmit arguments of
 // `foo` without any changes.
 }
step 1) Walter adds to std.stdio (or someone sends Walter) vwritef(TypeInfo[] types, va_list args); step 2) you call vwritef(_arguments,_argptr); without step 1 there isn't much you can do.
Aug 01 2005
next sibling parent Victor Nakoryakov <nail-mail mail.ru> writes:
Ben Hinkle wrote:
 "Victor Nakoryakov" <nail-mail mail.ru> wrote in message 
 news:dcl06d$2e4o$1 digitaldaemon.com...
 
Hi all.

What is the easiest way to transmit variadic arguments to function with 
variadic arguments? E.g.

void foo(...)
{
// some code
// bla bla bla

writef( ??? ); // here I want to transmit arguments of
// `foo` without any changes.
}
step 1) Walter adds to std.stdio (or someone sends Walter) vwritef(TypeInfo[] types, va_list args); step 2) you call vwritef(_arguments,_argptr); without step 1 there isn't much you can do.
:))) Easy, but unreal. -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russia
Aug 01 2005
prev sibling parent reply David L. Davis <SpottedTiger yahoo.com> writes:
In article <dcl3kc$2hoj$1 digitaldaemon.com>, Ben Hinkle says...
"Victor Nakoryakov" <nail-mail mail.ru> wrote in message 
news:dcl06d$2e4o$1 digitaldaemon.com...
 Hi all.

 What is the easiest way to transmit variadic arguments to function with 
 variadic arguments? E.g.

 void foo(...)
 {
 // some code
 // bla bla bla

 writef( ??? ); // here I want to transmit arguments of
 // `foo` without any changes.
 }
step 1) Walter adds to std.stdio (or someone sends Walter) vwritef(TypeInfo[] types, va_list args); step 2) you call vwritef(_arguments,_argptr); without step 1 there isn't much you can do.
Ben, to you mean wrapper functions like the following: if so, I've sent these in a email to Walter at the end of May, requesting these to be added to std.stdio. Guess it's time I resubmited them again, but this time add them to the current D v0.128 std.stdio file before emailing them to him again. :) Walter is a very busy man, so things don't always stick the first time. <g> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Aug 01 2005
parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:



















yeah, though I don't know if calling parameters _arguments and _argptr should be the names since they are the names made up by the compiler. My own preference would be for names not using the _ and in the case of _arguments I wish Walter would have picked a different name since that name does not indicate it is the types of the arguments and not the arguments themselves. Plus I know overloading ... works in this case but still personally I'd prefer the vfoo naming convention. Maybe that's just being paranoid about the ambiguity.
 if so, I've sent these in a email to Walter at the end of May, requesting 
 these
 to be added to std.stdio. Guess it's time I resubmited them again, but 
 this time
 add them to the current D v0.128 std.stdio file before emailing them to 
 him
 again. :)
ok
 Walter is a very busy man, so things don't always stick the first time. 
 <g>

 David L.

 -------------------------------------------------------------------
 "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
 -------------------------------------------------------------------

 MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html 
Aug 01 2005
parent "Ben Hinkle" <bhinkle mathworks.com> writes:
 My own preference would be for names not using the _ and in the case of 
 _arguments I wish Walter would have picked a different name since that 
 name does not indicate it is the types of the arguments and not the 
 arguments themselves.
To me more concrete I'd prefer something like _argtypes. That way there are two implicit variables _argptr of type void* and _argtypes of type TypeInfo[]. By convention user code that takes _argtypes and _argptr inputs would remove the _ in the parameter names to get argtypes and argptr.
Aug 01 2005