Path: utzoo!utgpu!attcan!uunet!iscuva!jimc From: jimc@iscuva.ISCS.COM (Jim Cathey) Newsgroups: comp.sys.mac.programmer Subject: Re: Arrays of functions in THINK C Keywords: Why does this not work? Message-ID: <1830@iscuva.ISCS.COM> Date: 3 Aug 88 15:02:38 GMT References: <2884@mit-amt.MEDIA.MIT.EDU> <9651@dartvax.Dartmouth.EDU> Organization: ISC Systems Corporation, Spokane, WA Lines: 38 In article <9651@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes: >Try > >(* gensub[1])(); > >I don't think it's a bug in Think. I think Think is handling the >situation properly. In the first form, you are attempting to call a >pointer to a function. In the second form, you are calling the >function referenced by the pointer. The reason the first form works >on "Vaxes, HPs, Suns, and in MPW" is rather obvious: "What else could >I possibly mean here?" K&R doesn't say anything about it. Anybody >care to eleaborate about what ANSI says? I've always hated this characteristic in compilers. Ever since many programmers around here cut their teeth on the old Mark Williams C compiler for the IBM PC. That little gem generalized the "what else could I possibly mean" principle to include converting structure passing operations into structure reference operations since it couldn't do the former (that is, it automatically supplied the '&' without even warning you). Combine this with the old "Of course ints and pointers are the same size, what else could possibly make sense?" You can imagine what happened when all these people moved to writing programs on the Vax and 68000. C's syntax is confusing enough without having it automagically convert selected expressions into something else. Dammit, so you can't have arrays of functions _this_ year. Don't forgive syntax mistakes/ shortcuts anyway! (Yes, I know arrays of functions don't make much sense, but so what? What about on your custom neural net/parallel super-femtocomputer?) +----------------+ ! II CCCCCC ! Jim Cathey ! II SSSSCC ! ISC Systems Corp. ! II CC ! TAF-C8; Spokane, WA 99220 ! IISSSS CC ! UUCP: uunet!iscuva!jimc ! II CCCCCC ! (509) 927-5757 +----------------+ Member: Society of the Excruciatingly Correct.