Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!newsfeed.internetmci.com!news.corpcomm.net!news From: Zach Heilig <zach@blizzard.gaffaneys.com> Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Compiler bug? Date: 09 Dec 1996 02:09:25 -0600 Organization: Corporate Communications Lines: 31 Sender: zach@murkwood.gaffaneys.com Message-ID: <87682c2l6y.fsf@murkwood.gaffaneys.com> References: <55tf99$6b5@garuda.synet.net> <57hsae$cpm@uwm.edu> <57l5t1$hr0@uriah.heep.sax.de> <57vt85$top@uwm.edu> <58em74$me3@uriah.heep.sax.de> NNTP-Posting-Host: dialup14.gaffaneys.com Mime-Version: 1.0 (generated by tm-edit 7.89) Content-Type: text/plain; charset=US-ASCII X-Newsreader: Gnus v5.3/Emacs 19.34 j@uriah.heep.sax.de (J Wunsch) writes: > Remember that > the prefix and postfix increment and decrement operators have > certainly been inspired by the PDP-11's ability to implement x++ and > --x directly by the CPU. This is most definitely incorrect. It is nice that the compiler can take advantage of the various CPU instructions, that's for sure. But according to Dennis Ritchie: (see http://www.lysator.liu.se/c/chistory.ps, page 5, the second paragraph) @ Thompson went a step further by inventing the ++ and -- operators, @ which increment or decrement; their prefix or postfix position @ determines whether the alteration occurs before or after noting the @ value of the operand. They were not in the earliest versions of B, @ but appeared along the way. People often guess that they were @ created to use the auto-increment and auto-decrement address modes @ provided by the DEC PDP-11 on which C and Unix first became popular. @ This is historically impossible, since there was no PDP-11 when B @ was developed. The PDP-7, however, did have a few `auto-increment' @ memory cells, with the property that an indirect memory reference @ through them incremented the cell. This feature probably suggested @ such operators to Thompson; the generalization to make them both @ prefix and postfix was his own. Indeed, the auto-increment cells @ were not used directly in implementation of the operators, and a @ stronger motivation for the innovation was probably his observation @ that the translation of ++x was smaller than that of x=x+1. That whole document makes for some interesting reading (it is 16 pages).