Volatile declaration in C++

Paul S. R. Chisholm psrc at pegasus.ATT.COM
Mon Oct 16 13:08:00 AEST 1989


In article <42718 at sgi.sgi.com>, karsh at trifolium.esd.sgi.com (Bruce Karsh) writes:
> Has anyone figured out how to make volatile work in cfront?  Are there any
> plans to make volatile an official part of the language?

> They are really useful when you are using shared variables.

>Bruce Karsh, karsh at sgi.com

It's dead, Jim.  (Gee, that'd be sort of confusing; can we just call
you Bruce?-)  It's like this:

In the beginning, there was C; and Ritchie wrote it, and he looked upon
it, and he said it was good.  And he and Kernighan wrote a book about
it.  And lo, the multitudes said, "Verily, it art good; but couldja add
this couple of things to it?"  And so Ritchie did so, and looked upon
it with its new features (enum types and structure assignment), and he
said it was still good.  And he wrote a memo describing what he had
changed, and if you were really hip, you managed to find yourself a
copy.

And lo, unto the the desert came a new prophet, and his name was
Stroustrup.  And he looked at C, and he looked back at Simula-69, and
he glanced at the various flavors of Smalltalk, and he said, "Verily,
there's some stuff I'd really like to use that ain't here."  And so
Stroustrup labored for many months, and he added classes to C, and data
abstraction, and he provided a way to write co-routines (sort of like
what were later called lightweight processes, I think, but send e-mail
rather than posting if I'm wrong); and he called it (I'll bet you think
you know what's coming) "C with Classes".  And the magnitudes looked
upon it, and as if with one voice, they said, "Huh?"  (Except for at
least one new MTS in Bell Labs, who looked upon the memo and drooled,
and beat his head against the closet door because he understood it
not.)  And so Stroustrup did it again, and this time he called it C++.
And the multitudes looked upon it again, and most of them studied it
carefully, and nodded their heads wisely, and in unison (or at least in
harmony) they did sayest, "Huh?"  But the world was changing, and this
time a few did figure out what the heck Stroustrup was talking about.

And there were also in that region three-and-many wise persons, and
they were called Implementors.  And these Implementors did study the
precepts of Kernighan and Ritchie, and they (if not their users) were
hip enough to find the memo on extensions, and with or without the help
of the Code of Johnson, they did write programs, and called them C
compilers.  And these Implementors did write run-time libraries for
these C compilers.  And many Implementors did Read The F***ing Manuals,
and wrotest libraries that allowed users to bring applications from one
platform to another without worry or fear.  But among these
Implementors, there were dark angels, who did not appreciate the
creation that had taken place in the earlier days; and lo, they wrote
compilers and libraries that were not compatible with other platforms.
And these Implementors, along with their users, cast themselves down
into dark pits, where they could no longer share code, or write
interesting books with Kernighan again (though he's put out at least
one science fiction novel, and *still* has a story that will appear in
THE LAST DANGEROUS VISIONS, if and when it's ever published.  But
that's another tale.-)

And so these Implementors did meet, and they gathered themselves
together, and they did form a Standards Committee.  And they agreed to
set down in one place an agreement of what was C and what was not C.
And they agreed not to follow in the path of the Dark Implementors, and
to codify only the existing art.  And then some of the Standards
Committee looked at the works of Stroustrup, and they said unto
themselves, "Hey, this Barn fellow has some really hot stuff."  And so
they incorporated function prototypes and the const keyword into their
Standard.  And they looked upon their Draft Standard, and they saw it
was good.

And then an Implementor (no doubt seduced by claims made for the Dark
Language) said, "Hey, aliases really, like, you know, bother me."  And
the other Implementors looked at aliases, and they saw that they were
grody.  And so they invented the keyword "volatile", which (among other
things) would announce the presence of aliases.  And they incorporated
the "volatile" keyword into their Standard.  And they looked upon their
Draft Standard, and they saw it was good; or at least most of them
thought it was.

And it came to pass that Ritchie, who had strived to do really good
global optimization in the presence of global pointers, had slumbered,
rising only long enough to invent the Fundamentals of UNIX(R)
Networking, which he called FUN, and which AT&T management later called
"streams".  And Ritchie woke to find the "volatile" keyword in the
Standard for his beloved C programming language.  And Ritchie did throw
lightning bolts, and cursed the darkness, and pointed out the
limitations in the "volatile" keyword, and pointed out how "const"
wasn't all it's cracked up to be.  (Try writing strchr() without
casting a pointer-to-constant-char into a pointer-to-not-necessarily-
constant-char.)  And he threatened to curse all their Software Houses,
and to vote against the standard.

And the Implementors were cowed by this show of forceful argument, and
they acquiesced.  And they removed the "volatile" keyword from their
Draft Standard, and they offered it to Ritchie; and he said it was
good.  And so all of the Implementors agreed to make their Draft
Standard into an official ANSI Standard.  And so it was done, except
that one Fortran programming threw sand into the works, and we're still
waiting for the paperwork to get finished.

And then the Implementors turned their full attention to C++, and they
said among themselves, "Oy, vey, here we go again."

Paul S. R. Chisholm, AT&T Bell Laboratories
att!pegasus!psrc, psrc at pegasus.att.com, AT&T Mail !psrchisholm
I'm not speaking for the company, I'm just speaking my mind.
UNIX(R) is a registered trademark of AT&T.



More information about the Comp.std.c mailing list