Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!rutgers!bellcore!clyde!watmath!watdragon!lion!smking From: smking@lion.waterloo.edu (Scott M. King) Newsgroups: comp.std.c Subject: Re: function returning pointer to itself Message-ID: <7797@watdragon.waterloo.edu> Date: 17 Jul 88 13:48:07 GMT References: <7725@watdragon.waterloo.edu) <664@goofy.megatest.UUCP> Sender: daemon@watdragon.waterloo.edu Reply-To: smking@lion.waterloo.edu (Scott M. King) Followup-To: comp.std.c Organization: U. of Waterloo, Ontario Lines: 38 In article <664@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: >From article <7725@watdragon.waterloo.edu), by smking@lion.waterloo.edu (Scott M. King): (me) >) In article <5485@batcomputer.tn.cornell.edu) olson@tcgould.tn.cornell.edu (olson) writes: >))Does the new C standard have a natural way to declare a >))function that returns a pointer to itself >) >) void *(* >) main() )() >) { >) return main; >) } >) >) Ugly eh??? > >Ugly? Yes. Correct? No. Don't feel too bad, though. Oh, don't worry, I don't feel too bad. My declaration *is* correct. It declares a function returning a pointer to a function returning a generic pointer. However, you could just as easily have any number of levels of indirection in such a declaration. Ie, the function could be declared as a function returning a pointer to a function returning a pointer to ... (any number of times) a function returning a generic pointer (void *) as in void *(*(*(*(*(*(*(*(*main())())())())())())())())(); Or, the function could similarly be declared as void * main(); since you can quite easily convert any pointer to a void * and back without loss of information. -- Scott M. King