Kevin Ryde on Tue, 10 Nov 2015 09:22:20 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Vector of args


Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> writes:
>
> If f is variadic,  the variadic arguments must grouped in a vector in the
> last component of A.

I'm trying to gently persuade Bill not to do this bit.  What does
anyone else think?

I would like call(f,[1,2,3]) for either f plain function or variadic.
I think in general-purpose code you often won't know which some f might
be, and even if you do then you'd prefer not to know for the sake of
uniformity, protection against future change to f, etc.  Otherwise if
code wants to allow both f then if I'm not mistaken it would have to
resort to maybe if(isvariadic(f),call(f,[v]),call(f,v)).

The call(f,[1,2,[3]]) on variadic is a shortcut for prepending args in
something like fprintf dispatching to Strprintf.  I think I might have
mentioned fprintf early on so I'm to blame for putting it in mind :-).
But I think not every call to a variadic will always want that, and as I
say it makes generality rather harder.

(Could contemplate a Vstrprintf(format,vector_of_args) as a helper for
new printf-like.  That wouldn't need a call().  Dunno how much use it
would get, and doesn't do anything Strprintf doesn't already, but if
it's almost-but-not-quite how the underlying C code is ... :)