comp.lang.ada
 help / color / mirror / Atom feed
From: "Paweł 'Nivertius' Płazieński" <nivertius@gmail.com>
Subject: Re: Access to function returning class-wide type
Date: Thu, 21 Aug 2008 13:56:35 +0200
Date: 2008-08-21T13:56:35+02:00	[thread overview]
Message-ID: <g8jl5o$oj8$1@registered.motzarella.org> (raw)
In-Reply-To: o2pfrvcvityp.gy34yp0t1m5l$.dlg@40tude.net

Dmitry A. Kazakov wrote:

>> What I need is a access type to 'constructor' of an derivate of abstract
>> object.
>> As I presented, there is a workaround, but that's not the 'right' way to
>> do it. I really want to do it without some tricky wrapping.
>> How do I define The_Access_Type to do what I want?
> See Ada.Tags.Generic_Dispatching_Constructor. It gives you a function
> constructing an object from the type tag, the parameters (Natural in your
> case) using the function you want (Proc). It goes as follows:
> 
> with Ada.Tags.Generic_Dispatching_Constructor;
> package A is
>    type Abstracted is abstract tagged null record;
>    function Proc (N : not null access Natural)
>       return Abstracted is abstract;
>    function Constructor is
>       new Ada.Tags.Generic_Dispatching_Constructor
>              (Abstracted, Natural, Proc);
> end A;

I belive that would work too, but at the cost of defining function Proc (N :
not null access Natural) return ... for each descendant type. That would be
another wrapper, so it's the same resolution to the problem as Proc_Wrapper
in my original code, assuming that I need Proc (N : Natural) as well.

Tell me that I'm wrong, please ;-)

-- 
Paweł Płazieński aka Nivertius
"In the end, there will be Ada, XML and gzip"



  reply	other threads:[~2008-08-21 11:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 10:13 Access to function returning class-wide type Paweł 'Nivertius' Płazieński
2008-08-21 10:33 ` Paweł 'Nivertius' Płazieński
2008-08-21 11:02 ` Dmitry A. Kazakov
2008-08-21 11:56   ` Paweł 'Nivertius' Płazieński [this message]
2008-08-21 13:34     ` Dmitry A. Kazakov
2008-08-22  4:53       ` Randy Brukardt
2008-08-22 23:50         ` Randy Brukardt
2008-08-21 12:01 ` Georg Bauhaus
2008-08-21 13:01   ` Paweł 'Nivertius' Płazieński
2008-08-21 13:50     ` Dmitry A. Kazakov
2008-08-21 19:30       ` Paweł 'Nivertius' Płazieński
2008-08-21 20:56         ` Dmitry A. Kazakov
2008-08-22  7:34           ` Paweł 'Nivertius' Płazieński
2008-08-21 17:02 ` Adam Beneschan
2008-08-21 19:22   ` Paweł 'Nivertius' Płazieński
replies disabled

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