Early C ?

Mar 16, 2006 7 Replies

I found this , from another post here

formatting link
about Early C, by Kernighan.



In the introduction it says.



"Disclaimer: This ``tutorial'' is presented as a historical document, not as a tutorial. Although it has lost little of its didactic value, it describes a language that C compilers today do no longer understand: the C of 1974."



As my C programing skills are somewhat dubious, just butchering



8051's usually. I read most of the article, and I'm still trying to understand the comment

"it describes a language that C compilers today do no longer understand: the C of 1974."



Most of the tutorial seems to make sense too me, what am I missing?



(Not a homework question, just trying to improve my skills)


martin


Main differences that I can think of:

(1) no 'void' in those days.

(2) function declaration is now rather different

(3) Initializer syntax is different ("int x = 1;" rather than "int x 1;")

(4) =operator replaced by operator= ("x += y;" rather then "x =+ y;")

(5) I think short and long modifiers weren't there at the time either; you got 'int' and 'int' was the size of a machine word.

(6) I'm not sure C had unions back in those days, which made certain types of systems programming task harder. (Exotica like bitfields were certainly not there, too).

pete

pete@fenelon.com [Support no2id.net: working to destroy Blair's ID card fraud]

Thanks, Pete

very helpful

martin

(clarifying context restored)

... snip ...

(7) structs could not be passed or returned by value.

"If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson More details at: Also see

The horse's mouth is of course Dennis Ritchie, you can find more discussion of early C including documents and source code from the period here:

formatting link

I should have pointed out that there are still remnants of this around today. The single struct namespace is why a lot of the system structures have redundant looking prefixes on the field names:

For example:

struct timeval { long tv_sec; /* seconds */ long tv_usec; /* microseconds */ }; Then in user code: struct timeval tv;

tv.tv_sec = 1; tv.tv_usec = 0; Why the tv_ on the front of the field names? This seems cleaner:

tv.sec = 1; tv.usec = 0;

But, that would have caused problems if some other structure definition used "sec" or "usec" as field names. So you put a prefix on all structure field names to try to avoid collisions.

Grant Edwards grante Yow! ANN JILLIAN'S HAIR at makes LONI ANDERSON'S visi.com HAIR look like RICARDO MONTALBAN'S HAIR!

Thanks. I came to the C party a little later ('86), and started working with pretty much the "K&R first edition" version of the language - so I was working backwards from what I remember of dmr's writings and the examples in that tutorial!

pete

pete@fenelon.com [Support no2id.net: working to destroy Blair's ID card fraud]

But in K&R, passing, returning and assigning structures wasn't allowed, this was new in K&R2 ('88).

Stef (remove caps, dashes and .invalid from e-mail address to reply by mail) "I take Him shopping with me. I say, 'OK, Jesus, help me find a bargain'" --Tammy Faye Bakker

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required