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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: abstract types and subprograms Date: Tue, 20 May 2014 16:11:53 +0200 Organization: cbb software GmbH Message-ID: References: <7puqh5yz4dyf.pov2dgfr2ky$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: QTaafVZuunHujkJPndFR7g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 2193 Xref: number.nntp.dca.giganews.com comp.lang.ada:186512 Date: 2014-05-20T16:11:53+02:00 List-Id: On Tue, 20 May 2014 15:28:29 +0300, Victor Porton wrote: > Dmitry A. Kazakov wrote: > >> 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. > > But can this: > > function From_Handle(Handle: Dummy_Record_Access) return Base_Object is > (Ada.Finalization.Limited_Controlled with Handle=>Handle); > > be implemented if the return type changes to Base_Object'Class? It does not make sense to me. Probably because it is not clear what you are going to achieve, smart pointer, an opaque handle to a C object, no idea. > It seems that returning Base_Object'Class wouldn't magically make it work > (without explicit override). Either you override or you don't. As I said, the criterion is whether the implementation is same for all class or different for some instances. > Or can it be done implementing Frorm_Handle only once (for Base_Object) with > automatic changing its signature for derived tagged types? Signature changes if the operation is primitive. It does not change if it is not primitive, e.g. class-wide. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de