[net.lang.c] Required Declaration of C Function Parameters

gwyn@BRL-VLD.ARPA (07/31/84)

From:      Doug Gwyn (VLD/VMB) <gwyn@BRL-VLD.ARPA>

That is a good point you raise.  For clarity, consider the example:

typedef	<stuff>	t_func;
extern t_func	func( t_func (*)(), int, char * );

Note the empty parentheses in the first parameter specification.
This is one case in which the "unspecified parameters" use of `()'
appears to be essential.  Note also that the value type `t_func'
must have been previously defined.

I think the key is that the type of the function `func' is just its
value type and the fact that it is a function, i.e. `t_func ()',
and the types of the parameters are not part of its formal type
although it is required that the parameter types be given in the
function declaration.  This is an important distinction that solves
the problem of recursive types.

kupfer@ucbvax.UUCP (Mike Kupfer) (08/05/84)

> I think the key is that the type of the function `func' is just its
> value type and the fact that it is a function, i.e. `t_func ()',
> and the types of the parameters are not part of its formal type
> although it is required that the parameter types be given in the
> function declaration.  This is an important distinction that solves
> the problem of recursive types.


This may be necessary with C's peculiar type declaration syntax,
but it's not true in general.  (The point being that maybe some
ingenious soul can come up with an acceptable solution for C.)
In Xerox's Cedar programming language, both the return type(s)
and the argument types are part of the procedure's formal
type.  As for recursive definitions, Cedar likes the following
declaration just fine:

	MyProcType: TYPE = PROC [MyProcType, Rope.ROPE];

which recursively defines the type of the first argument (and defines
a sort of string as the type of the 2nd argument).  You could use this
declaration in something like:

	MyProc: MyProcType = {...};
-- 
Mike Kupfer
kupfer.pa@Xerox.ARPA
kupfer@Berkeley
...!ucbvax!kupfer
"Even a sonic screwdriver can't get me out of this one!"

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (08/06/84)

Although the syntax of recursive type declaration can be made
simpler (as in the Cedar example), one will still run into
problems when type-checking recursive types unless some trick
similar in concept to the example I gave is used.  Note that
the idea of having two types of entity whose "useful" property
is the same but which have a different additional property for
cutting recursion short is commonly used, for example in the
axioms of a set theory free from Russell antinomies.  It is
possible to embed the recursion-truncation in an algorithm
in such a way that the two "levels" are not obvious, but they
are always there.