On Wed, Feb 10, 2010 at 10:10:31PM -0800, Brian Lavender wrote: > I guess in C, you can't overload a function? <snip>
You could use "...", like prinf() and scanf() use. ;) What I end up doing (and have seen other C-based APIs do) is something like this: void oldfunction(type1 arg1) { ...some code... } oops, I need two args! Rewrite time! void newfunction(type1 arg1, type2 arg2) { ...some code... } void oldfunction(type1 arg1) { newfunction(arg1, somedefault); } So now, anything that used oldfunction() still works as-is (API didn't change), but if I need the additional arguments, I can call the newer function (which really started life as a rename of the old function, then had some code added to it). It's kind of lame. I do appreciate PHP letting me only send args I need to, and providing defaults when declaring the function. e.g.: function getsomething($what, $how_many_days_ago = 7) { ... some code ...} I can call it as: $thisweek = getsomething("cookies"); $today = getsomething("cookies", 1); This also means the default can change w/o the callers caring. (Good or bad, depending ;) ) Rambling, sorry :) -bill! _______________________________________________ vox-tech mailing list vox-tech@lists.lugod.org http://lists.lugod.org/mailman/listinfo/vox-tech