Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!tektronix!tekcrl!tekfdi!videovax!bart From: bart@videovax.tv.Tek.com (Bart Massey) Newsgroups: comp.lang.c++ Subject: Re: More nits to pick at... Message-ID: <5423@videovax.tv.Tek.com> Date: 5 May 89 16:59:57 GMT References: <190@riunite.ACA.MCC.COM> <9279@alice.UUCP> <193@riunite.ACA.MCC.COM> <9291@alice.UUCP> Reply-To: bart@videovax.tv.tek.com (Bart Massey) Organization: Tektronix TV Measurement Systems, Beaverton OR Lines: 34 In article <9291@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: > In article <193@riunite.ACA.MCC.COM>, rfg@riunite.ACA.MCC.COM (Ron Guilmette) writes: > > >How can you declare a function which can accept a pointer > > >to itself as an argument (in a type-safe manner of course)? > > > > > > You can't in C++ or C. > > > > Well, so is anybody (other than me) concerned about this? > > Sure. > > But suppose C++ came up with a syntax for doing such a thing. > How would you translate it into C if C can't express it? Sigh. You've already done the syntactic and semantic analysis once, in your translator. You don't need C's type checking, and in fact don't want it in this case (you can always safely cast the parameter to any type you need). So, you just make the type be (void *). Or (int (*)()). Or whatever. In fact, you're probably trying to emit K&R C, for portability. It's not possible to declare a function which *won't* accept itself as an argument in K&R C, since old-style function declarations don't allow argument type checking. So... Bart Massey ..tektronix!videovax.tek.com!bart ..tektronix!reed.bitnet!bart P.S. -- This is the kind of thing I was talking about in an earlier article when I claimed that cfront had at least as a secondary goal the generation of C code which corresponded closely to the original and was easily understood by people. As I said before, there's nothing wrong with this. But this kind of reasoning makes it pretty apparent that this secondary goal does exist.