Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: missing ->= operator Message-ID: <5527@goanna.cs.rmit.oz.au> Date: 2 May 91 08:54:51 GMT Article-I.D.: goanna.5527 References: <9104291641.AA00534@dutiaa.tudelft.nl> <1991Apr30.165110.4165@unhd.unh.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 49 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. Well, of _course_ they were _implemented_ on such machines. But it is a MYTH that they reflect the behaviour of any machine. The designers of C have repeatedly denied this malignant rumour (there was a letter in SigPlan Notices last year about it), pointing out that -- C inherited the operations from B -- B was implemented as an *interpreter*, so hardware features weren't particularly relevant -- and if I remember correctly, the machine B was implemented on _didn't_ have such instructions. I would point out that -- Algol 68 has a whole raft of operators +:=, -:=, /:=, and so on. It was part of the culture at the time that "update operators" made programs clearer. An example from some Pascal code of mine: n.items[o.first + o.count] := n.items[o.first + o.count] + 1; Much clearer as n.items[o.first + o.count] +:= 1; The hardware very definitely did _not_ show through in Algol 68! -- Burroughs Extended Algol had a gimmick where the first following an assignment symbol could be '*', meaning "same variable as the one preceding the assignment symbol". Thus the BEAlgol version of the assignment above would be n.items[o.first + o.count] := * + 1; A virtue of that approach was that there was nothing special about binary operators: x := not *; x := - *; x := *.[0:8]; % extract bits an so on worked just fine. I can assume you that there was absolutely nothing on the Burroughs machine corresponding to "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. What's wrong with programmer conveniences? What else is a 'for' loop? Heck, _types_ in C are just a programmer convenience; C's ancestors managed without. (Yes, I have written BCPL programs, and yes, I have written "+" (integer add) when I meant "#+" (floating-point add).) -- Bad things happen periodically, and they're going to happen to somebody. Why not you? -- John Allen Paulos.