[KLUG Programming] Passing on variable argument lists.
Robert G. Brown
programming@kalamazoolinux.org
Sun, 08 Feb 2004 21:46:06 -0500
On Sun, 8 Feb 2004 21:22:12 -0500, Adam Williams wrote:
>On Sun, 2004-02-08 at 21:11, Robert G. Brown wrote:
>> Must you use vsprint in your app??
>No, that is just in the example; indicating that you have to have a
>special type of function to pass a va_list type (hence - I'm screwed).
I think this is ugly programming, and a bit of a kluge.
Then again, the prinf family of functions had their syntax subsumed is
subsequent versions of C (like C++, Objective C, then Java, etc).. since
this is messy at run-time, and slow... and sorta antithetical to what
all these languages are about (declaritive, scalar, strongly typed, early
binding, compiled).
>What I need to do it is create a function that accepts a variable
>argument list and then pass that variable argument list on to a function
>that itself accepts a variable argument list - it appears this can't be
>done (not in C anyway).
>From what I recall when writing stuff like this, not in-line, at least.
If you're NOT screwed, you're VERY CLOSE to being screwed! :)
You end up imposing a lot of requirements (perhaps impossible requirements)
on users of this sort of API, since they AT LEAST have to provide a level
of abstraction (like a function call level) between your stuff and whatever
variable parm stuff THEY want to do..
That can be rough to live with, especially when a lot of the stuff you WANT to
do is get some formatted strings into place on the fly, and you're trying to
provide an API that will be stable and easy to use.
My 2 cents is that you would do well to program away all this variable length
parameter list stuff if you can, but what do *I* know about your requirements?
>void myfunction (char* param1, char* param2, char* manyparams, ....) {
> ...some...stuff
> otherfunction(someparam, manyparams);
> } //note this is psuedocde.
>
>where otherfunction is declared (by someone else) as -
>otherfunction(sometype* someparam, char* manyparams, .....)
Is this Philips, Flathead, or Torx[r]? :)
Regards,
---> RGB <---