Re: pointer elimination in C

henry@zoo.toronto.edu (Henry Spencer)
Fri, 22 Oct 1993 20:14:06 GMT

          From comp.compilers

Related articles
pointer elimination in C miller@crx.ece.cmu.edu (Karen Miller) (1993-10-05)
Re:pointer elimination in C ghiya@flo.cs.mcgill.ca (1993-10-06)
Re: pointer elimination in C donawa@bluebeard.cs.mcgill.ca (Chris DONAWA) (1993-10-10)
Re: pointer elimination in C doug@netcom.com (1993-10-19)
Re: pointer elimination in C pop@dcs.gla.ac.uk (Robin Popplestone) (1993-10-22)
Re: pointer elimination in C macrakis@osf.org (1993-10-22)
Re: pointer elimination in C henry@zoo.toronto.edu (1993-10-22)
Re: pointer elimination in C mcdonald@kestrel.edu (1993-10-28)
Re: pointer elimination in C ted@crl.nmsu.edu (1993-10-29)
Re: pointer elimination in C rbe@yrloc.ipsa.reuter.COM (1993-11-01)
Re: pointer elimination in C mcdonald@kestrel.edu (1993-11-03)
Re: pointer elimination in C macrakis@osf.org (1993-11-03)
| List of all articles for this month |
Newsgroups: comp.compilers
From: henry@zoo.toronto.edu (Henry Spencer)
Keywords: C, history, design
Organization: U of Toronto Zoology
References: 93-10-032 93-10-096
Date: Fri, 22 Oct 1993 20:14:06 GMT

Robin Popplestone <pop@dcs.gla.ac.uk> writes:
>C was, as they would say in Congress, -very unique- in providing pointer
>arithmetic. This simply reflected the fact that good compilers had to be
>shoehorned into a tiny computer, the DEC-11, and there was a simple
>one-to-one mapping between something like *x++ and one machine
>instruction.


I don't believe this explanation holds water. The constructs in question
date back to C's predecessor, B, which did not run on the PDP-11 and was
not compiled.


The pointer arithmetic is directly inherited from BCPL, which had only one
datatype -- the word -- and consequently provided pointer arithmetic as a
trivial side effect of providing integer arithmetic. Indeed, in the early
C compilers the distinction between pointers and integers got pretty fuzzy
at times, although unlike BCPL it was not absent entirely.


The *x++ constructs, according to Dennis Ritchie, were Ken Thompson's
inventions, probably vaguely inspired by the autoincrement/decrement
hardware of the PDP-7 but significantly generalized from them. (And in
any case, the PDP-7 hardware facilities were not used in implementing
them.)


These were deliberate design decisions, not accidents of implementation
constraints.
--
Henry Spencer @ U of Toronto Zoology, henry@zoo.toronto.edu utzoo!henry
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.