missing ->= operator

Doug Gwyn gwyn at smoke.brl.mil
Thu May 2 05:09:22 AEST 1991


In article <1991Apr30.165110.4165 at unhd.unh.edu> jwm712 at unhd.unh.edu (Jonathan W Miner) writes:
>It is my opinion that the +=, &= etc operators were implemented on systems,
>such as DEC VAX that has two operand instructions.  Although it would
>be nice to have a ->=, it would be a programmer convenience, and it would
>still be compiled into the same code as p = p->next.  

No, you're not supposed to be thinking about what code is going to be
generated.

The main advantage of op= occurs in situations like:

	p->link->data[BIG_ROOM].flags |= BEEN_HERE;

where it would be tedious and error-prone to have to duplicate the LHS
as an operand, which would be necessary if the op= form did not exist.

There is no such justification for ->=, which seldom would be used in
contexts more involved than

	p = p->next;

which is easy enough to code as is.

There are some other more technical reasons involving type compatibility,
etc. but the above argument shows that it is not worth doing.



More information about the Comp.lang.c mailing list