[comp.lang.c] ???

raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) (04/11/89)

}} - 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@ptolemy.arc.nasa.gov)
"A hungry mob is an angry mob"

chris@mimsy.UUCP (Chris Torek) (04/11/89)

In article <1079@ptolemy.arc.nasa.gov> raymond@ptolemy.arc.nasa.gov
(Eric A. Raymond) writes:
>... 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 need not admit it. :-)  (For that matter, it is trivial to do this
in Emacs, and not at all hard in vi.)

>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 ";")

The gain appears because you may not have access to the source
definition.  People with El Stinko C Version 17.34 for the MiniMega
Model M probably do not *have* the source to fopen() or putc(), but
they *do* have a readable <stdio.h> containing the types (and, if they
are lucky, some suggestive names) for the arguments thereto.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris