??? (was Re: STDARG.H (va_arg stuff) ineffective)

Eric A. Raymond raymond at ptolemy.arc.nasa.gov
Tue Apr 11 13:22:12 AEST 1989


}} - Pass a count of the args such that a va_arg will decrement it and a
}}   predicate (i.e. va_argp()) to test whether args are left.
}
}The *number* of variable arguments is NOT sufficient information;
}you need also the *types* of the arguments.
}

Agreed, but this is an extension of the original question.  I know the
types of the args and their order, I just want to know how many are
there. 


}
}}This appears to have the same philosophical roots as passing arguments
}}by reference in C.  That is, in order to acheive X, both the caller
}}and callee must have have similar explicit notations.  I call this the "write
}}it in two places" syndrome.  This is also manifest in the header
}}file/source file redundancies (where you must maintain two files with
}}essentially the same (subset) information.  Flame and I'll explain.
}}(but this is a seperate issue).
}
}It is indeed.  Note, however, that natural languages also have
}redundancies; a limited amount of redundancy improves clarity by
}providing reassurance.

Seems like an anacronism to me.  You define the function (with a full
prototype), right?  So now why do I have to copy that same info over
to another file.  You must admit, it gets to be tedious.  I don't see
any info gain here.  (Both header declarations AND source definitions
have full function prototypes - those in .H are preceded by extern and
followed by a ";")

}at either the call site or the callee provides information about the
}number and types of arguments.  (Personally, I hate the `feature'
}that Pascal subroutines can modify parameters by declaring them
}`var' in a file I never see.  But then I think arrays should be
}passed by value :-) .)

But C lets you do that too in many different ways.  And typically
these are not specified in the function declaration (which is a sort
of contract between the caller and callee).  Furthermore, the style of
that C promotes can lead to extremely obscure errors.  (Pass a value,
use a pointer - sure strong typing, good style, a good compiler/lint
will obviate all this, but look what's taking up the slack.)

-- 
Eric A. Raymond  (raymond at ptolemy.arc.nasa.gov)
"A hungry mob is an angry mob"



More information about the Comp.lang.c mailing list