Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: missing ->= operator
Message-ID: <1991Apr30.223000.15032@zoo.toronto.edu>
Date: Tue, 30 Apr 1991 22:30:00 GMT
References: <9104291641.AA00534@dutiaa.tudelft.nl> <1991Apr30.165110.4165@unhd.unh.edu>
Organization: U of Toronto Zoology

In article <1991Apr30.165110.4165@unhd.unh.edu> jwm712@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...

No; they date to B on the pdp7, which had *one*-operand instructions.
These operators (and ++ and --) were always meant primarily as programming
conveniences, with the secondary possibility of more efficient code.

>Now for my question: how do the below operators compare speedwise?
>    a++;
>    a += 1;
>    a = a + 1;

Any C compiler which compiles different code for these is pretty stupid
(assuming that the evaluation of `a' has no side effects).  Modern compilers
will give you exactly the same code, running at the same speed, for all
of them.
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry@zoo.toronto.edu  utzoo!henry
