Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 01, 2005 Variadic arguments transmission | ||||
---|---|---|---|---|
| ||||
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
|
August 01, 2005 Re: Variadic arguments transmission | ||||
---|---|---|---|---|
| ||||
Posted in reply to Victor Nakoryakov | "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. |
August 01, 2005 Re: Variadic arguments transmission | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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 |
August 01, 2005 Re: Variadic arguments transmission | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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: # void writef(TypeInfo[] _arguments, va_list _argptr) # { # writex(stdout, _arguments, _argptr, 0); # } # # void writefln(TypeInfo[] _arguments, va_list _argptr) # { # writex(stdout, _arguments, _argptr, 1); # } # # void fwritef(FILE* fp, TypeInfo[] _arguments, va_list _argptr) # { # writex(fp, _arguments, _argptr, 0); # } # # void fwritefln(FILE* fp, TypeInfo[] _arguments, va_list _argptr) # { # writex(fp, _arguments, _argptr, 1); # } 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 |
August 01, 2005 Re: Variadic arguments transmission | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis | > # void writef(TypeInfo[] _arguments, va_list _argptr) > # { > # writex(stdout, _arguments, _argptr, 0); > # } > # > # void writefln(TypeInfo[] _arguments, va_list _argptr) > # { > # writex(stdout, _arguments, _argptr, 1); > # } > # > # void fwritef(FILE* fp, TypeInfo[] _arguments, va_list _argptr) > # { > # writex(fp, _arguments, _argptr, 0); > # } > # > # void fwritefln(FILE* fp, TypeInfo[] _arguments, va_list _argptr) > # { > # writex(fp, _arguments, _argptr, 1); > # } 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 |
August 01, 2005 Re: Variadic arguments transmission | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | > 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.
|
Copyright © 1999-2021 by the D Language Foundation