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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1108a1,66253344eaef63db X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,66253344eaef63db X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,66253344eaef63db X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-29 19:58:57 PST Newsgroups: comp.lang.ada,comp.object,comp.lang.c++ Path: bga.com!news.sprintlink.net!howland.reston.ans.net!swrinde!emory!nntp.msstate.edu!olivea!news.bu.edu!inmet!dsd!stt From: stt@dsd.camb.inmet.com (Tucker Taft) Subject: Re: Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Message-ID: Keywords: Ada 9X, C++, object-oriented Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <1994Sep27.165203.9192@swlvx2.msd.ray.com> <36bt0c$17oo@watnews1.watson.ibm.com> <1994Sep29.021209.20769@swlvx2.msd.ray.com> Date: Thu, 29 Sep 1994 14:01:45 GMT Xref: bga.com comp.lang.ada:6321 comp.object:6903 comp.lang.c++:31026 Date: 1994-09-29T14:01:45+00:00 List-Id: In article <1994Sep29.021209.20769@swlvx2.msd.ray.com>, John Volan wrote: >NHC = ncohen@watson.ibm.com (Norman H. Cohen) writes: > >NHC>One variation on this is to declare recursive types meant to serve as the >NHC>parents of types Employee and Office, but to provide no operations for >NHC>these recursive types. Then, in child packages, declare Employee and >NHC>Office themselves as derived types and declare primitive operations in >NHC>those child packages: >NHC> >NHC> with ... ; -- other stuff needed by Employee >NHC> with ... ; -- other stuff needed by Office >NHC> >NHC> package Employees_And_Offices is >NHC> >NHC> type Employee_Parent is tagged limited private; >NHC> type Employee_Pointer is access all Employee'Class; >NHC> >NHC> type Office_Parent is tagged limited private; >NHC> type Office_Pointer is access all Office'Class; > >This solution suffers from the same problem as Mark Biggar's suggestion: >These access types only give clients an "opaque" view of the designated objects. >The useful primitive operations for these objects won't be declared until we >get to the concrete *subclasses* declared later. So a client would have to >resort to using a non-typesafe Unchecked_Conversion to "downcast" one of these >pointers into designating the corresponding concrete subclass. As mentioned in a previous post, there is no need to use non-typesafe Unchecked_Conversion. A safe, checked, explicit "downcast" (or "narrowing") conversion is permitted in Ada 9X when the operand is of a class-wide type, or of an access-to-class-wide type. See RM9X-4.6(15, 23, 42, 50);5.0. >-- John Volan >-- Company => "Raytheon Missile Systems Division", >-- E_Mail_Address => "jgv@swl.msd.ray.com", S. Tucker Taft stt@inmet.com Intermetrics, Inc. Cambridge, MA 02138