Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: learning C declaration syntax Message-ID: <250@xyzzy.UUCP> Date: Tue, 8-Sep-87 15:07:08 EDT Article-I.D.: xyzzy.250 Posted: Tue Sep 8 15:07:08 1987 Date-Received: Wed, 9-Sep-87 06:30:09 EDT References: <8877@brl-adm.ARPA> <8088@mimsy.UUCP> <1623@tekchips.TEK.COM> <956@bc-cis.UUCP> <223@xyzzy.UUCP> <2352@aw.sei.cmu.edu> Organization: Data General, RTP NC. Lines: 55 > firth@sei.cmu.edu (Robert Firth) >> throopw@xyzzy.UUCP (Wayne A. Throop) >> [...] the K&R tutorial which states that declaration >>syntax mimics expression syntax. But once one knows this about >>declarations, why is it still difficult? > There seem to me two main sources of confusion for other than C experts. > The first is a use of graphical symbols that is, by almost any standard, > highly eccentric. I agree that C chooses its symbols in an ideosyncratic manner, and for someone trying to remember both C-and-something-else this is problem. But the difficulty seems to be something much worse than that. People aren't forgetting what symbols stand for what, or the details of whether prefix operators or postfix operators are "done first". The confusion is more fundamental. No, people are confused to the point of not knowing how to proceed. This is what I find strange. Pick up K&R, find the table of operators and their prescedence, and you have everything you need. Yet people are so confused that they don't even do *this*, and I am at a total loss to explain it. > The combination of prefix and postfix syntax also of course creates > problems over strength of binding, and hence the need for all those > parentheses. Absolutely correct. But again, the degree of confusion seems totally out of line with the provoking cause. If nobody told you about anything, if there were no tables of the rules, one could get lost. But presumably people are told about the anomaly of indirection being prefix. Having been told about this, and having a wealth of reference materials (K&R for example being particularly widespread), why do they forget? Surely people could at least remember that someing is anomalous here, and remember to look it up in the table of operators? So I guess I'm agreeing that (a[i]^.f^(x)) is much clearer than (*(*(a[i]).f)(x)). And I'll agree that it would even be clearer than the simplest way I can see to say it in X3J11-style C: (a[i]->f(x)), because of all the arcane abbreviations that that entails (and it doesn't help the declaration syntax any). But even so... is it really *that* hard? Do the ideosyncratic choices of symbol and the misbegotten choice of prefixness for indirection really weigh *that* heavily? Further, if symbols are arcane and hard to learn, in all seriousness now, wouldn't it be better to say a SUBSCRIPTED BY i INDIRECT SELECT f INDIRECT INVOKE WITH x rather than a[i]^.f^(x) -- 14. Are you tired? If not, go back to step 7. 15. Go to sleep. Then, wake up, and go back to step 7. --- Knuth- Fundamental Algorithms Vol 1. -- Wayne Throop !mcnc!rti!xyzzy!throopw