Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 (Tek) 9/26/83; site azure.UUCP Path: utzoo!linus!security!genrad!decvax!tektronix!azure!stevesu From: stevesu@azure.UUCP (Steve Summit) Newsgroups: net.unix Subject: functions returning pionters to functions Message-ID: <2430@azure.UUCP> Date: Mon, 12-Dec-83 22:28:27 EST Article-I.D.: azure.2430 Posted: Mon Dec 12 22:28:27 1983 Date-Received: Wed, 14-Dec-83 01:44:22 EST Organization: Tektronix, Beaverton OR Lines: 85 And it came to pass that I desired to code a function returning a pointer to a function returning an integer, and with good reason, for it was not a hack; and I was distressed, for I was unsure as to what form the incantation should take, but I crossed my fingers, and I did guess, and I did type int (*getroutine())(name, table) for the name of the routine was getroutine, and its arguments were name and table; and I did luck out, for the compiler was pleased, and it did emit code, and the code did run, for this was a lowly 11, running 2.8bsd, and some things were easier then. And the program was good, and it went forth, and multiplied, and it came to pass, that I desired to compile it again, on a vax under 4.1 . And the compiler did puke, and it did shout syntax error, for it did consider my incantation a blasphemy; and not recognizing the declaration of a function, it did consider the rest of my file to be in error as well. And I did repent, for I had used the heathen method of trial and error, and although I had skirted the first trial, I had been eventually judged to be in error. And I sought comfort in the scriptures, and I consulted the Book of Brian and Dennis, as I should have done in the first place, and in chapter 5, on page 116, I did read, that the declarations should be studied with some care, and I did study, with some care; but the example given was merely a pointer to a function, and not the function returning the same, that I desired. And as I studied the example, I did reason that if int *a was the declaration for a pointer to an integer and int *a(x) was the declaration for a function of x returning a pointer to an integer; then if int (*a)() was the declaration for a pointer to a function returning an integer, then surely int (*a)()(x) should be the declaration for a function of x returning a pointer to a function returning an integer, and this did I try, but still was the compiler displeased, and I did reason that perhaps another level of parenthesis might be required, as in (int (*a)())(x) or perhaps ((int)(*a)())(x) and these too did I try, but still was the compiler displeased, and still did it continue to pass numerous judjements on my program, beginning with "syntax error" on the afflicted line, and continuing with others too numerous to mention. And I did realize, that I was again regressing into the accursed method of trial and error, and that along that path surely did not lie salvation, and so now do I beseech you, my brothers and sisters on the net, and fellow supplicants of unix, to guide me if you can, out of my darkness and into the light, that I might declare a function returning a pointer to a function returning an integer, in a way equally blessed under the deities of 2.8 and 4.1 . Steve Summit tektronix!tekmdp!stevesu P.S. And it came to pass, that I recieved many flames, as if directly from the gates of Hell, for the net was not amused, and it did suggest that I should have submitted my beseechment to net.religion, or /dev/null; and if this be the case, then I apologize, but I am in a curious mood today, and ask forgiveness, for I know not what I do.