Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!att!pacbell.com!tandem!zorch!xanthian From: xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) Newsgroups: comp.std.c++ Subject: Re: parameter type matching (was Re: the SUN way) Message-ID: <1990Dec24.112015.4426@zorch.SF-Bay.ORG> Date: 24 Dec 90 11:20:15 GMT References: <9012240347.AA00685@decpa.pa.dec.com> Organization: SF-Bay Public-Access Unix Lines: 34 diamond@tkou02.enet.dec.com ("diamond@tkovoa") writes: > [...] The Extended Pascal Standard does have a "type of" construct, > approved in 1987, which solves exactly this problem. In C-based > languages, there is a syntactic difficulty because the function's > return type is specified before the parameter types. The processor has > to analyze the parameters first. Here in pseudo-C syntax: > typeof(x) *bsearch(const any (*x)[], const typeof(x) *, > unsigned, unsigned, > int(*)(const typeof(x) *, const typeof(x) *)); > Notice that the first parameter names the prototype-scoped identifier > x, whose type is invoked in other parts of this prototype. If the > programmer wanted to name other parameters and copy their types as > well, it could also be done. I know that the urge to preserve C's write-only, unparsable syntax forever into the future is nearly insurmountable, but that is really ugly and hard to read. How about: typeof(x) *bsearch(const any (*x)[], const oftype(x) *, unsigned, unsigned, int(*)(const oftype(x) *, const oftype(x) *)); Also, looking at it, I would assume that "x" is of type "pointer to function", and so question the "*"s within the prototype of bsearch; i.e., it is hard to understand to what, and with what stopping point, your typing has tied x. Kent, the man from xanth. -- But then, I was _born_ confused.