c programming style

hwe at lanl.ARPA hwe at lanl.ARPA
Fri Jul 19 05:31:12 AEST 1985


The original purpose of:
	char *p;

	while (*p++)...

was to allow the PDP-11 auto increment mode to be exploited.
The code above would generate something like...

	tstb @(r0)+

while the code:
	while (*p)
		p += 1;
would/could (depending on the smarts of the compiler) generate an "inc"
instruction.

In discussions of C, the following points should be remembered...

1.	The inventors (Ritchie and friends) of C were GOOD assembly
	programmers who recognised the utility of the new-fangled
	structured concepts.

2.	C was primarily a vehicle for VERY GOOD assembly language
	programmers to take advantage of the new structured programming
	while keeping the close-to-the-machine power needed (??) for
	system programming.

While I do support active discussions of programming style, p++ vs p += 1
and so on, have deeper significance than just style.
				Skip Egdorf



More information about the Comp.lang.c mailing list