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: border1.nntp.dca3.giganews.com!backlog3.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!newsfeed.fsmpi.rwth-aachen.de!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: A good program that not compile Date: Wed, 21 May 2014 17:24:31 +0300 Organization: Aioe.org NNTP Server Message-ID: References: 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: 2162 Xref: number.nntp.dca.giganews.com comp.lang.ada:186540 Date: 2014-05-21T17:24:31+03:00 List-Id: Now it works! 100% No need to change Ada standard. The latest listing follows: -- my.ads with Ada.Finalization; package My is type Abstract_Handle is abstract new Ada.Finalization.Limited_Controlled with record Handle: Integer; end record; function Obtain_Handle(Object: Abstract_Handle) return Integer is abstract; overriding procedure Initialize(Object: in out Abstract_Handle); type File_Handle is new Abstract_Handle with null record; overriding function Obtain_Handle(Object: File_Handle) return Integer; end My; -- my.adb package body My is overriding procedure Initialize(Object: in out Abstract_Handle) is begin Object.Handle := Obtain_Handle(Abstract_Handle'Class(Object)); end; overriding function Obtain_Handle(Object: File_Handle) return Integer is begin return 123; -- Suppose 123 is a file handle, for an example end; end My; -- main.adb with My; with Ada.Text_IO; procedure Main is X: My.File_Handle; begin Ada.Text_IO.Put_Line(Integer'Image(X.Handle)); end; -- Victor Porton - http://portonvictor.org