comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: abstract types and subprograms
Date: Tue, 20 May 2014 13:22:30 +0300
Date: 2014-05-20T13:22:30+03:00	[thread overview]
Message-ID: <llfad4$he$1@speranza.aioe.org> (raw)

I am now an Ada novice. I started to write librdf bindings for Ada.

The following produces the error:

gnatmake -ws -c -u -P/home/porton/Projects/librdf-ada/librdf.gpr rdf-
base.adb
gcc-4.6 -c -g -O2 -gnat2012 -I- -gnatA /home/porton/Projects/librdf-ada/rdf-
base.adb
rdf-base.ads:20:04: function that returns abstract type must be abstract
gnatmake: "/home/porton/Projects/librdf-ada/rdf-base.adb" compilation error


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?


-- 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;
   
private
   
   type Base_Object is new Ada.Finalization.Limited_Controlled with
      record
         Handle: Dummy_Record_Access;
      end record;     
   
end RDF.Base;

-- rdf-base.adb
package body RDF.Base is
   
   function Get_Handle(Object: Base_Object) return Dummy_Record_Access is 
(Object.Handle);
   
   function From_Handle(Handle: Dummy_Record_Access) return Base_Object is
      (Ada.Finalization.Limited_Controlled with Handle=>Handle);
   
end RDF.Base;

-- 
Victor Porton - http://portonvictor.org


             reply	other threads:[~2014-05-20 10:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20 10:22 Victor Porton [this message]
2014-05-20 10:51 ` abstract types and subprograms 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
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