I've always had a bit more luck with the "typedef each step of the construction" rule-of-thumb. Also, I tend to hide anything as complex as "pointer-to-array-of-pointers-to-functions" (even though you memorize this idiom pretty quickly after an hour in the kernel) behind library ADT's, so you're never indexing an array, but rather passing an index and a whatever_t* to whatever_get(w, index).
An ML like notation would be even more cool:<p><pre><code> char *str[10];
str : [10] (*char)
char *(*fp)( int, float *);
fp : *((int, *float) -> *char)
void (*signal(int, void (*fp)(int)))(int);
signal : (int, *(int -> void)) -> *(int -> void)
</code></pre>
(Oh. That last declaration did make some sense, after all…)<p>Really, how did they manage to chose such an inconsistent, unreadable syntax for their declarations? Is there any rational explanation?
Fails on nested arrays.<p><pre><code> char *foo[10][20];
</code></pre>
The method described would indicate that this is a array 10 of pointers to array 20s of chars.<p>This is incorrect. It is an array 10 of array 20s of pointers to chars.
I don't see where the spiral comes in. The following rule is simpler:<p>(1) Begin at the variable name, read from left to right, then go back to the name and read from right to left.<p>(2) Give precedence to expressions in parentheses.<p>For example:
char <i>(</i>fp)( int, float * )<p>The innermost expression is (* fp). Nothing to the right of the fp. so read to the left: "* ", it's a pointer. Next, we go right and see an arguments list, so it's a pointer to a function taking these arguments. Go back to where we started and read right to left: Pointer to a function taking (int,float *) that returns a pointer to char.
Meh! This is just an overly complication of the right-left rule, which makes you think about "complex" 2D geometry instead of a couple of simple spatial pointers in the declaration you are trying to parse..<p>The easier, more useful version:
<a href="http://ieng9.ucsd.edu/~cs30x/rt_lt.rule.html" rel="nofollow">http://ieng9.ucsd.edu/~cs30x/rt_lt.rule.html</a>
It is amazing to me the number of people who would take the time to make ASCII graphics in their replies.<p>I'm blessed that even munging 15+ Linux c/c++ libraries lately I haven't run into anything requiring this - though my Intro to C class, at Merit College twenty five years ago did teach to this rule.<p>Hats off to you anyway...