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: 103376,e94d0e47489de27d,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-20 14:02:00 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!gatech!newsfeed.pitt.edu!dsinc!ub!newserve!npnews!mcs!ruckert From: ruckert@mcs.mcs.newpaltz.edu (Martin Ruckert) Newsgroups: comp.lang.ada Subject: Question: Extensible subobject? Date: 20 Jan 1995 22:02:00 GMT Organization: SUNY College at New Paltz Message-ID: <3fpbso$6g2@motss.newpaltz.edu> NNTP-Posting-Host: mcs.mcs.newpaltz.edu Summary: What language support do I get in Ada95 to solve the following problem: Given a class A specifying a subobject t of type S. I define a subclass of SS of S. Can I define a subclass AA of A by redefining the type of f to be SS instead of S? X-Newsreader: TIN [version 1.2 PL2] Date: 1995-01-20T22:02:00+00:00 List-Id: I don't know enough about Ada to find the best solution to the following problem using Ada. I would be interested in a solution to include it in a comparison of major object oriented languages. So, someone out there might know the answer. Problem: An interactive application presents texts to the user in windows. Most of the texts are read only (help, messages, menus). The base class is RO_Text, it has methods to provide read access to the text. A subclass of RO_Text is Edit_Text, which defines some additional data fields to do a more complex storage management and it provides additional methods to allow changes to the text (e.g. insert a character). The base class for windows is RO_Window, it specifies a field t to be a pointer to an RO_Text and has methods to perform all the updating of the screen to make the text visible. I want the class Edit_Window to be a subclass of RO_Window. Edit_Window needs additional methods to service requests to change the text shown (e.g. inserting a character). This new methods will update the screen and it should forward the message to its text. I can create an Edit_Text and store the pointer to it in the field t of the Edit_Window. So the text subobject has methods to perform the changes, but the type of t is a pointer to a RO_Text. Will it allow access to the necessary methods of the Edit_Text? If I use a type conversion on t it needs runtime overhead for checking. Type conversions should be avoided if anyway? I would rather in Edit_Window redefine the type of t to be a pointer to Edit_Text. This enables the compiler to check that my assignments to t are correct and spares the type conversion and the test associated with it later. Is it possible ?? How to handle it best ?? Martin Address: ruckert@mcs.newpaltz.edu