Topic: Why "public" "private" "protected


Author: allan_w@my-dejanews.com (Allan W)
Date: Mon, 21 Apr 2003 17:34:02 +0000 (UTC)
Raw View
musiphil@bawi.org (KIM Seungbeom) wrote
> jon@belinfante.fsnet.co.uk ("Jon Belinfante") wrote
> > "Howard Gardner" <usenet@hgardner.com> wrote
> > > Fluff question, but it's always puzzled me a little. Either "commmon" or
> > > "communal" are a better fit than "protected." Anyone know how
> > > "protected" was picked?
> >
> > protected seems a perfectly fine keyword to me. It is self-explanatory.
>
> Self-explanatory? How? Protected against what?
>
> The meanings of "public" and "private" are obvious, and so is their
> contrast, but I too have wondered how "protected" came in between,
> to mean something that's open to the derivatives (like "public")
> but closed to others (like "private").

According to dictionary.com, your alternatives, "Common" and
"communal," have the same root word. Communal means "of or belonging
to a commune" and common means "Belonging to or shared equally by two
or more." Not too far off the mark, really; I think that most of us
would say that the protected member was "owned" by the base rather than
the derived classes, but the point is that the derived classes can use
it. If it wasn't for the existing (and conflicting) definition in
Fortran, perhaps Stroustrup would have considered it.

(Then again, maybe he considered the words to be too ... well, common.
Keywords shouldn't be words that programmers are extremely likely to
want to use as identifiers.)

Besides common and protected, what other keywords could have been used?
And how would he decide which one to use?

Believe it or not, I am in possession of a rare home movie of Bjarne
Stroustrup, and (by the most fantastic of coincidences) it was made at
the exact moment he made this decision. Sorry, I'm not allowed to
divulge the source for this rare home movie -- some of the principals
are still alive.

Anyway, this particular home movie was taken in Stroustrup's private
office at Bell Labs. Mr. Stroustrup had just filled out a piece of
paper with six possible names on it, and he was holding a "Dungeons
and Dragons"-style "D10" dice. (This dice has 20 sides, with the
numbers 0 to 9 each represented twice.) The camera quickly pans past
the chart, and with freeze-frame it's possible to make out most of
the words:

    0 -- blackjack
    1 -- protected
    2 -- common
    3 -- publicforderivedbutprivateforeveryoneelse
    4 -- PublicForDerivedButPrivateForEveryoneElse
    5 -- notpublic
    6 -- bjarne
    7 -- stroustrup
    8 -- commune
    9 -- mani*****
(#8 has the word "common", which is crossed out -- followed by the
phrase "somewhatpublic", also crossed out -- and then the word "auto,"
which is crossed out, and there's an arrow with the phrase "almost as
bad as static" -- and finally the word "commune.")
(Sadly, most of word #9 is in a shadow, and not readable)

First, Stroustrup rolls a 4. "So that's the keyword," he mutters, but
then he reconsiders. "This would not only be the longest keyword in
the history of any language anywhere -- it would also be the first one
in C or C++ that had capital letters." (This was long before C's "_Bool")
"I better not set a precedent this way!"

So he rolls again, and comes up with a 6. "Hee hee hee, I like it!" he
says. "But... will people think I'm an egotist? Better not to be so
self-serving."

His third roll is a 0. "That seemed like a good idea when I wrote it,"
he says, "but will people take it seriously? Also, will I be hated by
the people who prefer poker, or even non-gambling games?"

So he rolls again, and he gets another 4. Although Stroustrup says
nothing, the frustration is evident on his face. "Turn off that camera,"
he says. Whoever was taking the pictures fakes him out -- the camera
moves away, but the film does not stop.

There's another roll that the camera cannot see. "Arrgh," he cries. The
camera is secretly moved back again, just as he picks up the die.

His sixth roll is 7. Stroustrup takes a deep breath, and lets it out
slowly. "The heck with it -- I'll just use protected," he says, and
to make it official, he types it in to an Nroff-file as the camera
fades to black.

I think that's what Jon Belinfante meant by "self-explanatory".

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: musiphil@bawi.org (KIM Seungbeom)
Date: Sat, 19 Apr 2003 04:23:49 +0000 (UTC)
Raw View
jon@belinfante.fsnet.co.uk ("Jon Belinfante") wrote in message news:<b6u3lf$5so$1@news7.svr.pol.co.uk>...
> "Howard Gardner" <usenet@hgardner.com> wrote in message
> news:dxmja.112062$M7.2458037@twister.tampabay.rr.com...
> > Fluff question, but it's always puzzled me a little. Either "commmon" or
> > "communal" are a better fit than "protected." Anyone know how
> > "protected" was picked?
>
> protected seems a perfectly fine keyword to me. It is self-explanatory.

Self-explanatory? How? Protected against what?

The meanings of "public" and "private" are obvious, and so is their
contrast, but I too have wondered how "protected" came in between,
to mean something that's open to the derivatives (like "public")
but closed to others (like "private").

--
KIM Seungbeom <musiphil@bawi.org>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: jon@floorboard.com (Jonathan Biggar)
Date: Tue, 8 Apr 2003 16:18:53 +0000 (UTC)
Raw View
Howard Gardner wrote:
> Fluff question, but it's always puzzled me a little. Either "commmon"
> or "communal" are a better fit than "protected." Anyone know how
> "protected" was picked?

"common" or "communal" would have too much connotation overlap with
Fortran, where it means something very different.

My guess is that Stroustrup liked the alliteration.

--
Jon Biggar
Floorboard Software
jon@floorboard.com
jon@biggar.org

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: jon@belinfante.fsnet.co.uk ("Jon Belinfante")
Date: Tue, 8 Apr 2003 16:19:05 +0000 (UTC)
Raw View
protected seems a perfectly fine keyword to me. It is self-explanatory.


"Howard Gardner" <usenet@hgardner.com> wrote in message
news:dxmja.112062$M7.2458037@twister.tampabay.rr.com...
> Fluff question, but it's always puzzled me a little. Either "commmon" or
> "communal" are a better fit than "protected." Anyone know how
> "protected" was picked?
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]
>


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: usenet@hgardner.com (Howard Gardner)
Date: Sat, 5 Apr 2003 04:20:00 +0000 (UTC)
Raw View
Fluff question, but it's always puzzled me a little. Either "commmon" or
"communal" are a better fit than "protected." Anyone know how
"protected" was picked?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: bjorn.roald@attbi.com (Bjorn Roald)
Date: Sun, 6 Apr 2003 21:30:59 +0000 (UTC)
Raw View
Howard Gardner wrote:

> Fluff question, but it's always puzzled me a little. Either "commmon" or
> "communal" are a better fit than "protected." Anyone know how
> "protected" was picked?
>

I think "protected" is fine.  But as for why it was picked, just an educated
guess, but "protected" was (and is) a keyword in Simula.

http://www.iro.umontreal.ca/~simula/ManPage/images/sg_150.html

Bjorn

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: allan_w@my-dejanews.com (Allan W)
Date: Mon, 7 Apr 2003 19:12:17 +0000 (UTC)
Raw View
usenet@hgardner.com (Howard Gardner) wrote
> Fluff question, but it's always puzzled me a little. Either "commmon"
> or "communal" are a better fit than "protected." Anyone know how
> "protected" was picked?

I wasn't there, so this is just a guess.

I think that when Stroustrup was devising the new language, he picked
new keywords largely the same way that's done now: he looked for a
word with the correct meaning, but not largely used in the language.

I don't know about "communal," but "common" was used very often (in C
programs) with several meanings. One meaning that I am familiar with
actually comes from FORTRAN's idea of global (rather than file-scope)
variables. I know for a fact that it also had other uses, possibly as
a variable name in some programs.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]