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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!news.ecp.fr!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: abstract types and subprograms Date: Tue, 20 May 2014 13:22:30 +0300 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: LRua1LhEwYx/r1KnMXeYtA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.12.4 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 2386 Xref: number.nntp.dca.giganews.com comp.lang.ada:186506 Date: 2014-05-20T13:22:30+03:00 List-Id: 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