comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: abstract types and subprograms
Date: Tue, 20 May 2014 13:55:25 +0200
Date: 2014-05-20T13:55:25+02:00	[thread overview]
Message-ID: <7puqh5yz4dyf.pov2dgfr2ky$.dlg@40tude.net> (raw)
In-Reply-To: llfad4$he$1@speranza.aioe.org

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


  parent reply	other threads:[~2014-05-20 11:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 10:22 abstract types and subprograms Victor Porton
2014-05-20 10:51 ` mockturtle
2014-05-20 11:45   ` Victor Porton
2014-05-20 16:27     ` Robert A Duff
2014-05-20 19:52       ` Dmitry A. Kazakov
2014-05-24 18:49         ` Robert A Duff
2014-05-24 19:41           ` Dmitry A. Kazakov
2014-05-20 11:55 ` Dmitry A. Kazakov [this message]
2014-05-20 12:28   ` Victor Porton
2014-05-20 14:11     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox