From: | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
Newsgroups: | comp.compilers |
Date: | Wed, 3 Mar 2010 07:41:20 +0000 (UTC) |
Organization: | California Institute of Technology, Pasadena |
References: | 10-02-024 10-02-039 10-02-086 10-02-088 10-03-003 10-03-005 |
Keywords: | design, C |
Posted-Date: | 05 Mar 2010 10:55:26 EST |
Chris F Clark <cfc@shell01.theworld.com> wrote:
(snip)
> The basic idea of reserved word (i.e. a keyword you can't use for
> anything else) specifying a declaration followed by a list of
> identifiers being declared is a sound one and is used in the
> languages leading upto C.
Which languages were leading up to C?
Two languages which had some of the features that went into C,
and that were reasonably used at the time, were Fortran and PL/I.
[C was mostly based on BCPL. See http://cm.bell-labs.com/cm/cs/who/dmr/chist.html
-John]
While many PL/I features were modified considerably before
being used in C, a few, such as the form of comments, stayed
pretty much the same.
Both Fortran and PL/I have no reserved words. I am not so sure
about Fortran, but it seems to have been intentional for PL/I.
A large list of reserved words (reference COBOL) means that
programmers have to know those words, even if they don't need
those features. C has a relatively small list if you don't
include names reserved for the library, but they are still there.
Also, the use of reserved words complicates adding new features
to the language later. Adding new reserved words can make old
valid programs invalid.
(snip)
> The reason I recommended the person consider Pascal is that it has
> all those problems solved and solved simply. C is not a
> particularly easy language to parse. If you go trying to extend C,
> it is very easy to make the language completely unparseable. A few
> tiny bandaids on C don't resolve those issues.
As far as I know, a lot of work went into each extension of Fortran to
make sure that no ambiguities crept in, and, except for a few specific
exceptions, older programs would still be valid.
In most cases, reserved words are reserved to make it easier for the
compiler, not for the programmer.
I have seen C compilers that refused a variable named new. (That is,
C/C++ compilers in C mode.)
-- glen
Return to the
comp.compilers page.
Search the
comp.compilers archives again.