Hi Keith, > I was taught to: > > - find the symbol name > - look right, for parentheses > - look left, token by token, to find the type
Yes, that's a simplification of the `right left' rule that I first saw in Paul and Gail Anderson's _Advanced C: Tips and Techniques_, https://amzn.to/2rn2LPv And with it, signal(3) becomes intelligible. :-) void (*signal(int sig, void (*func)(int)))(int); > char const *foo; > would be read as: > - foo is a variable (not function) > - foo is a pointer (to data of type not yet established) > - foo is constant > - foo is a constant pointer to data of type char I'd read it as foo foo is a * pointer to const const char char Note how `const' and `char' stand for themselves. > const char *foo; > *unambiguously* reads as: Well, they're both unambiguous! > - foo is a variable (not function) > - foo is a pointer (to data of type not yet established > - foo is a pointer to data of type char > - foo is a pointer to data of type char, which is constant This is a more clumsy read: foo foo is a * pointer to char a char const that is const I used your syntax for decades and only switched in the last year after chatting to a programmer that's always done it the other way since introducing the Small C compiler into his company to replace assembler; so, quite a while. He'd had no external influences so worked out what he thought was logical. `const char * const foo' has const come before its thing one time, `char', and after another, `*', and that seems poor. Plus the key thing, `char', is buried a bit. `char const * const foo' has `const' consistently come after its thing, and the first thing I read is `char'. It works consistently. $ awk '{s=""; for (i=NF; i>=1; i--) s=s" "$i; print substr(s, 2)}' <<\E | > char foo > char const foo > char * foo > char const * foo > char * const foo > char const * const foo > E > sed 's/foo/& is a/; s/\*/pointer to/g' foo is a char foo is a const char foo is a pointer to char foo is a pointer to const char foo is a const pointer to char foo is a const pointer to const char $ I accept it isn't groff's style; it wasn't mine until recently. But it does seem logical, consistent, and if it wasn't for historic reasons, probably the sole grammar that C would allow. (I don't care about C++.) -- Cheers, Ralph. https://plus.google.com/+RalphCorderoy