Varargs. Or, these days, stdargs. It's how C lets you define functions that take a variable number of arguments.
Why do I hate it? Because, even though you're forced to view the argument list opaquely, there's no argument count! That is, the standard says the variable length argument list lives in a magic va_arg thingie, you must use the Magic Functions to get the individual arguments out, and you must have the magic ... signature to note varargs in the function declaration, but... the standard can't be bothered to mandate that an argument count is passed. This seems utterly mad.
Yes, I know, it's an extra parameter to be constructed and passed, but the caller knows how many parameters its passing in at compile time and that it's passing them in as part of a variable length parameter list so calculation's a compile-time cost. The callee has to figure out how many parameters are being passed anyway, either with an explicit count or something like a format string, so it's not like this information's not available or passed. Not just throwing a count in as something that must be there and instead force people building or using vararg functions to do it anyway, but by hand which is far more error-prone.
Yeah, I'm sure there were Very Good Reasons to not mandate this in the standard. I have no idea what they are, but I'm sure they all suck.
C. Bleah.Posted by Dan at October 9, 2003 10:41 AM | TrackBack (0)