[net.lang.c] Where did ++ come from?

dmr@dutoit.UUCP (06/21/86)

Phaedrus@eneevax guessed that a lot of notation in C came from PDP-11
assembly language, and Chris Torek's reply did indeed drag me out
of my torpor.

Nothing in the C syntax came from the PDP-11, because all the relevant
parts were imported from B, which was in use before the PDP-11
existed.  In fact things are somewhat the other way around; the reason
the Unix PDP-11 assembler resembles B (and C) more than does DEC's, is
that I wrote the first Unix PDP-11 assembler, in B, before we had a DEC
assembler.  It was written from the machine description.  It used * and
$ rather than @ and # because the former were analogous respectively to
the B notation and to other assembly languages I knew, and (equally)
because @ and # were the kill and erase characters.

As to ++ and --:  these were Thompson inventions as far as I know,
or at least the idea of using them in both prefix and postfix form.
No doubt the autoincrement cells in the PDP-7 contributed to the idea,
but there was a significant generalization, or rather isolation of the
significant operations into ++ -- and *, as Chris pointed out.

If you haven't heard of autoincrement cells, here is the idea: certain
locations (010-017) in low memory in the PDP-7 (and also the -8, but
just one cell, probably 010), acted like ordinary memory locations,
unless indirection was applied through them.  In that case, after the
indirect reference, 1 was automatically added to them.  It was useful
for stepping through arrays, especially because these machines lacked
index registers.

* came from the version of BCPL we were using.  (Pure BCPL used "rv"
for "*" and "lv" for "&").

By the way,  B had assignment versions of all the binary operators,
including === and =!=.  Since it didn't have &&, the question of =&&
did not arise.  The ones missing from C were dropped for lack of interest.

	Dennis Ritchie

tim@ism780c.UUCP (Tim Smith) (06/27/86)

In article <2140@dutoit.UUCP> dmr@dutoit.UUCP writes:
> It used * and $ rather than @ and # because the former were
> analogous respectively to the B notation and to other assembly
> languages I knew, and (equally) because @ and # were the kill and
> erase characters.

So, why does C use # for the preprocessor instead of $?
-- 
Tim Smith                       USENET: sdcrdcf!ism780c!tim || ima!ism780!tim
"hey, bay-BEE'...hey, bay-BEE'" Compuserve: 72257,3706
				Delphi || GEnie: mnementh