From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1108a1,12f4d07c572005e3 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,12f4d07c572005e3 X-Google-Attributes: gid103376,public X-Google-Thread: ff6c8,12f4d07c572005e3 X-Google-Attributes: gidff6c8,public X-Google-Thread: 10db24,12f4d07c572005e3 X-Google-Attributes: gid10db24,public X-Google-Thread: f43e6,12f4d07c572005e3 X-Google-Attributes: gidf43e6,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Java Risks (Was: Ada News Brief - 96-05-24 Date: 1996/06/05 Message-ID: <4p44m2$tc5@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 158597869 distribution: world references: <4o56db$p66@ns1.sw-eng.falls-church.va.us> organization: IBM T.J. Watson Research Center reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada,comp.sw.components,comp.object,comp.software-eng,comp.edu Date: 1996-06-05T00:00:00+00:00 List-Id: In article , Richard Riehle 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