Article View: comp.lang.misc
Article #6311Re: language commenting constructs
From: David Chase
Date: Wed, 15 Mar 1989 01:32
Date: Wed, 15 Mar 1989 01:32
78 lines
3395 bytes
3395 bytes
In article <10460@lanl.gov> jlg@lanl.gov (Jim Giles) writes:
>// Or better yet, I use a language like C++ which
>// always terminates comments beginning with '//'
>// at the end of a line - automatically.
...
>It is doubtful that anyone designing a new language would
>consider the old-fashioned C-like syntax to be desireable.
Sigh. At the risk of sounding like a broken record (not that that
stops anybody else on the net), there were languages before C (hence
older) and they used the
// this is a comment to EOL style of comments.
Specifically, there was BCPL, C's grandparent. I have often wondered
why some features present in BCPL were removed in C; I construct my
own explanations, but they tend to be unflattering to the designers of
C. BCPL had its warts, of course, but I often think that they threw
out the baby and kept the bathwater. Examples of "nice" things
discarded include:
* // comments
* VALOF <block> expressions
For example, here's how to use a "case" statement within
an expression:
VALOF SWITCHON x INTO $(
CASE 'a':
CASE 'e':
CASE 'i':
CASE 'o':
CASE 'u':
RESULTIS vowel
CASE 'y':
RESULTIS sometimes
DEFAULT:
RESULTIS consonant
$)
(This has reappeared within GCC, I believe)
* extended relational tests (e.g. '0' <= ch <= '9')
* many fewer parentheses (at the expense of added keywords, but it
was a lot nicer to read)
* good generic types (actually, only one type, but it
includes pointers, integers, procedures, you name it)
* :=/= instead of =/==
This is a matter of taste, but the character-counting
justifications never made much sense to me, especially since
BCPL also used = for initialization, allowed elision of
redundant semicolons, and permitted multiple assignments.
Thus,
int a = 1;
int b = 2;
int c = 3;
would be rendered as
LET a,b,c = 1,2,3
If a variable's value were subsequently changed, then := would
be used. For example,
a := b + c
* cleaner syntax for function definitions (VALOF helps here)
For example,
LET min2(a,b) = a < b -> a,b
AND min3(a,b,c) = a < b -> min2(a,c), min2(b,c)
AND abs(a) = a < 0 -> -a,a
I just defined three functions; you can all construct their
C versions and compare.
I have always wondered what caused the designers of C to leave all
this fine stuff out; it's not like the BCPL compiler was a pig, and
few of these features had any real effects on portability or
efficiency (the generic single type is apparently the biggest
headache). Enquiring minds want to know what the reasoning was behind
the choices made for C.
David
Technical Details
Message-ID:
<39273@oliveb.olivetti.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!oliveb!Ozona!chaseReferences:
<1543@zen.UUCP> <10460@lanl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!oliveb!Ozona!chase From: chase@Ozona.orc.olivetti.com (David Chase) Newsgroups: comp.lang.misc Subject: Re: language commenting constructs Message-ID: <39273@oliveb.olivetti.com> Date: 15 Mar 89 01:32:07 GMT References: <1543@zen.UUCP> <10460@lanl.gov> Sender: news@oliveb.olivetti.com Reply-To: chase@Ozona.UUCP (David Chase) Organization: Olivetti Research Center, Menlo Park, CA Lines: 78