The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: scj@yaccman.com (scj@yaccman.com)
Subject: [TUHS] speaking of early C compilers
Date: Mon, 27 Oct 2014 10:09:21 -0700	[thread overview]
Message-ID: <2c9c14d6fd7d2e98ae0bc98d7f593ff9.squirrel@webmail.yaccman.com> (raw)
In-Reply-To: <0F0B9BFC06289346B88512B91E55670D2F86@EXCHANGE>

Casts were invented as part of the port of Unix to the 32-bit Interdata. 
The early Unix system manuals actually printed the structure declarations
for things like directory inodes in the manual -- there were no header
files.  This meant a massive amount of work when we wanted to use
different structures for the 32-bit system.  To make matters worse, many
system calls returned -1 as an error indication, and on the Interdata
loading an integer from location -1 gave an unrecoverable machine fault
(!).  As a final blow, the lack of type checking between pointers and
structure members made it very hard to catch old code at compile time.

The cast syntax, arguably one of the ickiest parts of C syntax, was
invented in desperation -- we needed the feature, and there was no good
syntax proposal.  I blush to admit that the one Dennis chose is one that I
suggested, largely because (unlike some of the others) it was easy to
implement in Yacc.

We hacked a version of Lint to force structures whose physical declaration
locations were different to appear to be different structures, even if
they were identical.  Then, as header files were introduced, we could find
all the user-level structure declarations that were copied from the man
pages and fix them.  This was extremely valuable, and allowed a summer
intern from Princeton to convert most of the user-level programs to V7 in
a summer.

As an aside, one of the hairiest pieces of code I ever wrote was the part
of PCC that handled structure declarations--it had to understand the "old
style anything goes" syntax, but if the compiler decided that there was
some attempt to use the new semantics, it changed modes and retroactively
complained about possible type mismatches.  The code was festooned with
assertions, most of which were very short (memory being precious) -- one
or two words like "junk" or "garbage".  When compiling the V7 file system,
Ken managed to totally confound my code by declaring a structure that had
an array whose dimension was computed using a sizeof of another structure
declared inside of the sizeof.  He came to me one afternoon with a strange
expression on his face and asked "Hey Steve, what is a gummy
structure?"...




  parent reply	other threads:[~2014-10-27 17:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27 10:32 Jason Stevens
2014-10-27 13:03 ` Brantley Coile
2014-10-27 13:34   ` Ronald Natalie
2014-10-27 13:40     ` random832
2014-10-27 14:04       ` Clem Cole
2014-10-27 15:04       ` Dave Horsfall
2014-10-27 17:09 ` scj [this message]
2014-10-27 20:35   ` Ronald Natalie
2014-10-27 21:34     ` Clem Cole
2014-10-28  1:09       ` Dave Horsfall
2014-10-28  2:06         ` Clem Cole
2014-10-28 12:22           ` Ronald Natalie
2014-10-28 12:42             ` Clem Cole
2014-10-28 13:03               ` Ronald Natalie
2014-10-28 22:02                 ` John Cowan
2014-10-27 13:46 Noel Chiappa
2014-10-27 13:54 Jason Stevens
2014-10-27 14:48 Noel Chiappa
2014-10-27 15:09 ` Ronald Natalie
2014-10-27 15:13 ` Dave Horsfall
2014-10-27 16:52 ` Dan Cross
2014-10-27 15:48 Noel Chiappa
2014-10-27 16:25 ` Dave Horsfall
2014-10-28  0:16   ` John Cowan
2014-10-27 16:50 Norman Wilson
2014-10-27 18:16 Nelson H. F. Beebe
2014-10-28  1:55 Jason Stevens
2014-10-28 12:52 ` Ronald Natalie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c9c14d6fd7d2e98ae0bc98d7f593ff9.squirrel@webmail.yaccman.com \
    --to=scj@yaccman.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).