comp.lang.ada
 help / color / mirror / Atom feed
* abstract types and subprograms
@ 2014-05-20 10:22 Victor Porton
  2014-05-20 10:51 ` mockturtle
  2014-05-20 11:55 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 10+ messages in thread
From: Victor Porton @ 2014-05-20 10:22 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-05-24 19:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2014-05-20 12:28   ` Victor Porton
2014-05-20 14:11     ` Dmitry A. Kazakov

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