comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: Java Risks  (Was: Ada News Brief - 96-05-24
Date: 1996/06/05
Date: 1996-06-05T00:00:00+00:00	[thread overview]
Message-ID: <4p44m2$tc5@watnews1.watson.ibm.com> (raw)
In-Reply-To: 4o56db$p66@ns1.sw-eng.falls-church.va.us


In article <Pine.GSO.3.92.960604155403.19912B-100000@nunic.nu.edu>,
Richard Riehle <rriehle@nunic.nu.edu> writes: 

|> >    class C {
|> >       protected: 
|> >          typedef ... T;
|> >          static T x;  // perfectly legal
|> >          struct S {
|> >             T x;      // illegal: protected "member" T inaccessible inside
|> >          } y;         //    a struct, despite nesting.
|> >    }
...
|>                                                 In all honesty, very few
|>   C++ programmers would design a class with such an obviously ugly
|>   profile.

But it's not an ugly profile, it's a perfectly reasonable idiom.  S and T
are strictly part of the implementation of class C, so the programmer
wants to keep them hidden in protected declarations.  The C++ code above
is the direct analog of the following Ada code: 

   package C is

      type C_Type is private;
      ...

   private

      type T is ...;

      type S is
         record
            x: T;   -- T is usable here even though hidden outside
                    --   of package C.
            ...
         end record;

      type C_Type is
         record
            y: S;
            ...
         end record;

   end C;

   package body C is
      ...
      x: T;  -- Corresponds to the C++ static member above, but is hidden
             --    in the package body, where it belongs.
      ...
   end C;

As an aside, here's the latest C/C++ pitfall to bite me: 
*** Error: Mixed metaphor.           ^^^^^^^    ^^^^

     char * six_string_guitar[6] =
        { "E string",
          "A string",
          "D string"
          "G string",
          "B string",
          "E string"
        };

Because of the missing comma following "D string" (did you notice it?),
six_string_guitar is actually quietly initialized to {"E string",
"A string", "D stringG string", "B string", "E string", 0}.  (Adjacent
string constants are concatenated, and default values--zero in the case
of a pointer--are used for missing elements in an initializer.)  What a
language!

--
Norman H. Cohen    ncohen@watson.ibm.com




  parent reply	other threads:[~1996-06-05  0:00 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-24  0:00 Ada News Brief - 96-05-24.txt [1/1] AdaIC
1996-05-27  0:00 ` Tucker Taft
1996-05-28  0:00   ` Richard Riehle
1996-05-29  0:00     ` Andreas Zeller
1996-05-30  0:00       ` Robert Dewar
1996-06-01  0:00         ` AdaWorks
1996-06-01  0:00           ` Robert Dewar
1996-06-01  0:00         ` AdaWorks
1996-06-01  0:00           ` Robert Dewar
1996-06-01  0:00             ` Mike Young
1996-06-03  0:00               ` Robert Dewar
1996-06-04  0:00             ` Richard Riehle
1996-05-30  0:00       ` Java Risks (Was: Ada News Brief - 96-05-24 Richard Riehle
1996-05-31  0:00         ` Java Risks (should be Java mis-speak) The Right Reverend Colin James III
1996-06-02  0:00           ` Richard Riehle
1996-06-03  0:00             ` Tucker Taft
1996-05-31  0:00         ` Java Risks (Was: Ada News Brief - 96-05-24 Brian N. Miller
1996-06-02  0:00           ` Richard Riehle
1996-06-03  0:00           ` Ken Garlington
1996-06-04  0:00             ` Bill Brooks
1996-06-06  0:00               ` Bjarne Stroustrup <9758-26353> 0112760
1996-06-06  0:00                 ` Robert Dewar
     [not found]         ` <4omoh4$k0f@ansible.bbt.com <4ov36b$1665@watnews1.watson.ibm.com>
1996-06-04  0:00           ` Richard Riehle
1996-05-27  0:00 ` Ada News Brief - 96-05-24.txt [1/1] Brian Rogoff
1996-05-31  0:00 ` Java Risks (Was: Ada News Brief - 96-05-24 Jon S Anthony
1996-06-01  0:00   ` Java Risks David Hopwood
1996-06-02  0:00   ` Java Risks (Was: Ada News Brief - 96-05-24 Richard Riehle
1996-06-01  0:00 ` Bob Crispen
1996-06-05  0:00   ` Alan Brain
1996-06-03  0:00 ` Norman H. Cohen
1996-06-03  0:00   ` Imonics Corporation
1996-06-07  0:00   ` Peter Wentworth
1996-06-05  0:00 ` Norman H. Cohen [this message]
1996-06-05  0:00   ` Bill Brennamw
1996-06-08  0:00   ` Brian N. Miller
1996-06-09  0:00 ` Jim Kingdon
  -- strict thread matches above, loose matches on Subject: below --
1996-06-03  0:00 Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox