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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7508aa0d80b8bf66 X-Google-Attributes: gid103376,public From: Andreas Winckler Subject: Re: Inheritance and Polymorphism in Ada !! Date: 1999/10/15 Message-ID: <3806DC34.1513E8B1@frqnet.de>#1/1 X-Deja-AN: 536985121 Content-Transfer-Encoding: 7bit References: <7u64k3$l1d$1@hiline.shinbiro.com> X-Accept-Language: de Content-Type: text/plain; charset=us-ascii X-Complaints-To: news-support@xlink.net X-Trace: kilbeggan.xlink.net 939973605 4683 194.121.221.60 (15 Oct 1999 07:46:45 GMT) Organization: FREQUENTIS Network Systems GmbH Mime-Version: 1.0 NNTP-Posting-Date: 15 Oct 1999 07:46:45 GMT Newsgroups: comp.lang.ada Date: 1999-10-15T07:46:45+00:00 List-Id: Chango Cho schrieb: > > Do they exist in Ada? Yes, but in my opinion polymorphism is kind of restricted in Ada. See this example: 1 procedure inheritance_polymorphism is 2 3 type type_a is tagged record 4 first_field : integer; 5 end record; 6 7 type type_b is new type_a with record 8 second_field : integer; 9 end record; 10 11 type pointer_type is access all type_a'class; 12 pointer : pointer_type; 13 14 begin 15 pointer := new type_b; 16 type_b(pointer.all).second_field := 1; 17 end inheritance_polymorphism; See line 16, the type of the referenced object must be known in advance. With "pointer.second_field :=1" the compiler fails. It seems that the strong typing restricts the features of polyormism in Ada. Any comments? Am I wrong? However, when it comes to real_world_applications like the air traffic control systems I do, polymorphism and dynamic memory allocation is a DO_NOT anyway. Greetings, AW -- ========================================================= Andreas Winckler Dipl.-Ing. Software engineering FREQUENTIS Network Systems GmbH Tel: (+49) (7541) 282 - 462 Fax: (+49) (7541) 282 - 299 http://www.frqnet.de