franka@mentor.UUCP (Frank A. Adrian) (05/17/86)
Yes, I know the purists don't want their langauge munged around, but having been working on a program that uses several arrays of linked lists, I was wondering about: (A very long computataion which gets you to a pointer) ->= next; which of course is equivalent to (A...) = (A...)->next; Of course, this would be checked by lint (or some of the newer cc's) to make sure you are assiging a pointer field to the same type of pointer. With this construct, a nice list search could be written as: for(x = foo; x && (x->key != key); x ->= next); /* ^^^^^^^^^^^^^^^^^^^^ I know, non-portable, but it works for me */ return x; I know this is probably unnecessary for efficiency, as most optimizing compilers will put the left hand side in a register, but it does increase clarity in some cases, such as: a[x++] = a[x]->next; or a[x] = a[x++]->next; I have trouble remembering in what order the increment takes place. Is it before or after the assignment (No fair peeking in K&R!)? The semantics of a[x++] ->= next; is clear -- the increment takes place after the asignment. In any case, I don't think that this would mung up the language too bad, and comments about how tough it is to add "features" to compilers don't bother me at all (I don't have to write them, I just have to use them). Frank Adrian The opinions expressed here are in no way reflect those of ANY sane person or organization.