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 Path: border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: abstract types and subprograms Date: Tue, 20 May 2014 13:55:25 +0200 Organization: cbb software GmbH Message-ID: <7puqh5yz4dyf.pov2dgfr2ky$.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: QTaafVZuunHujkJPndFR7g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:186509 Date: 2014-05-20T13:55:25+02:00 List-Id: On Tue, 20 May 2014 13:22:30 +0300, Victor Porton wrote: > By the philosophy of programming From_Handle should be non-abstract but > return an abstract object, and From_Handle should be automatically > overridden for descendants non-abstract objects. > > What is wrong? You cannot automatically override without knowing the implementation, which you don't in advance. If you know it, then it is same for all class. See below. > -- rdf-base.ads > with Ada.Finalization; > with Interfaces.C.Pointers; > > package RDF.Base is > > -- Internal > type Dummy_Record is null record; > > -- Internal > type Dummy_Record_Access is access Dummy_Record; > > type Base_Object is abstract new Ada.Finalization.Limited_Controlled with > private; > > function Get_Handle(Object: Base_Object) return Dummy_Record_Access with > Inline; > > function From_Handle(Handle: Dummy_Record_Access) return Base_Object with > Inline; function From_Handle(Handle: Dummy_Record_Access) return Base_Object'Class; Logically, a handle can point on an object of any type derived from Base_Object, so it is a class. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de