New assignment operator ->= ?

Rob "The" Mayoff mayoff at walt.cc.utexas.edu
Wed Feb 21 05:02:14 AEST 1990


In an article entitled New assignment operator ->= ?, wietse at wzv.win.tue.nl (Wietse Z. Venema) enlightens us with:

>Don't forget the .= operator. Unfortunately, such language features would 
>prohibit other language perversions such as:
>
>		a ^+= b <-> a ^= a += b <-> a = a ^ a + b
>		p ->= q <-> p -= p >= q <-> p = p - p > q
>
While I am sure you at least partially joking, it seems that you dislike my
suggestion.  Let me respond:

  The .= operator would probably never be used.  I don't think a structure can
be a member of itself, and I don't think a union can be a member of itself, so
you can't assign a structure variable to a member of itself.  On the other
hand, a pointer to a structure can be a member of that same structure, and
assigning that member of the structure to a variable pointing to that structure
is a logical, I might even say common, operation.  While it would not cause the
compiler to generate less instructions, as += might (at least in
non-optimizing compilers), it is shorter to type and no less readable (at
least, no less readable than a+=b, etc).

Furthermore, the += operator, and its siblings give the idea of "incrementing"
the variable, or scaling it, etc.  To me, incrementing a numerical variable
seems analogous to advancing a pointer to a linked list along that list.

So far, I've gotten five positive responses.  I also got one response that
pointed out that -> is not exactly a binary operation, since the right-hand
identifier indicates a structure element, not a variable. And, of course,
the response I am replying to.

Anyone else have an opinion on this?

Also, can anyone (and I'm sure someone can) tell me how to contact the ANSI
C committee?
 __
/\_\ Rob Mayoff
\/_/ mayoff at ccwf.cc.utexas.edu



More information about the Comp.lang.c mailing list