----- Original Message -----
From:"Larry McVoy" <lm(a)mcvoy.com>
...
I get that it doesn't scale but man, oh man, do I love the
early Unix
data structures that had one namespace. I kinda wish you hadn't
fixed
that Steve.
What was the push that made you fix it?
It came from Dennis, so I can't say why he decided to change it. The
argument for it is that many structures would have similar names and
similar functions, such as "next" and "prev" in linked lists.
Adding a new linked list action could be done much more easily by
copying the code and changing the declaration, instead of having to
change ab_next into cd_next, and then dealing with the inevitable
typos that would sneak a use of ab_next into code for cd.
Just to clarify, from the beginning I considered C to be Dennis'
language. I would make suggestions, and sometimes he adopted them
(I'm responsible for ^ as the exclusive OR, for example). In one
case, with casts, we were porting Unix to the 32-bit Interdata and
desparately needed a cast operator, but couldn't find a syntax that we
liked that was general enough to handle casts to, for example,
structure pointers or function pointers. Matters were approaching a
crisis, and one evening I played with the yacc grammar and worked out
the strengths and weaknesses of the top three candidates. I
suggested the one that I felt was best, and that was what was adopted.
The simple rule was that you formed a cast by taking a declaration
of what you wanted the result to be, remove the variable being
declared, and enclose the rest in parens. I had implemented it and
saw that it worked (because the port was based on PCC, there wasn't
nearly the pressure to change the PDP-11 compiler). The fact that
we could explain the syntax in one sentence led us to feel like it
would be reasonable. The problem, of course, is that we didn't put
anything back where the variable had been, so when you encounter a
nontrivial cast you have to enumerate all the possible places a
variable might be and determine which one is syntactically correst
while your brain turns to mush...
Steve