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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fa22a73e140a6fd1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.99 with SMTP id nr3mr8605025pbc.2.1326029134647; Sun, 08 Jan 2012 05:25:34 -0800 (PST) Path: lh20ni156315pbb.0!nntp.google.com!news2.google.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Object-Oriented style question Date: Sun, 8 Jan 2012 14:25:19 +0100 Organization: cbb software GmbH Message-ID: References: <4f098fcb$0$6577$9b4e6d93@newsspool3.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: PPt+vSuBRqtkVsMLa1J3Dg.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-01-08T14:25:19+01:00 List-Id: On Sun, 08 Jan 2012 12:52:46 +0000, Simon Wright wrote: > I don't see why anyone would use anything other than your Info: > > function Info (Item : in T) return Value; > > You may need to pass values of T'Class (or access T'Class) around, but > this shouldn't affect the primitive. And it seems to me it makes it much > simpler from a teaching point of view (but IANAT!) In some rare cases Info need to be is contravariant ("final"), then: function Info (Item : in T'Class) return Value; When T is supposed to use some reference counting scheme. Then due to lack of either MI or interface inheritance in Ada, there must be an extra interface type declared. E.g. type T_Interface is limited interface ...; function Info (Item : in T_Interface) return Value is abstract; type T_Implementation is ... and T_Interface; overriding -- This one does the job function Info (Item : in T_Implementation) return Value; type T_Handle is ... and T_Interface ... overriding -- This one delegates to the implementation function Info (Item : in T_Handle) return Value; function Info (Item : in T_Handle) return Value is begin return Item.Ptr.Info; end Info; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de