From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Object-Oriented style question
Date: Sun, 8 Jan 2012 14:25:19 +0100
Date: 2012-01-08T14:25:19+01:00 [thread overview]
Message-ID: <kifc70vpqmss.ohkfe45n9t94.dlg@40tude.net> (raw)
In-Reply-To: m2aa5y73vl.fsf@pushface.org
On Sun, 08 Jan 2012 12:52:46 +0000, Simon Wright wrote:
> I don't see why anyone would use anything other than your Info:
>
> function Info (Item : in T) return Value;
>
> You may need to pass values of T'Class (or access T'Class) around, but
> this shouldn't affect the primitive. And it seems to me it makes it much
> simpler from a teaching point of view (but IANAT!)
In some rare cases Info need to be is contravariant ("final"), then:
function Info (Item : in T'Class) return Value;
When T is supposed to use some reference counting scheme. Then due to lack
of either MI or interface inheritance in Ada, there must be an extra
interface type declared. E.g.
type T_Interface is limited interface ...;
function Info (Item : in T_Interface) return Value is abstract;
type T_Implementation is ... and T_Interface;
overriding -- This one does the job
function Info (Item : in T_Implementation) return Value;
type T_Handle is ... and T_Interface ...
overriding -- This one delegates to the implementation
function Info (Item : in T_Handle) return Value;
function Info (Item : in T_Handle) return Value is
begin
return Item.Ptr.Info;
end Info;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2012-01-08 13:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-08 12:45 Object-Oriented style question Georg Bauhaus
2012-01-08 12:52 ` Simon Wright
2012-01-08 13:25 ` Dmitry A. Kazakov [this message]
2012-01-08 14:18 ` Robert A Duff
2012-01-08 20:32 ` Martin Dowie
2012-01-08 20:52 ` Robert A Duff
2012-01-09 22:34 ` Adam Beneschan
2012-01-09 23:21 ` Robert A Duff
2012-01-10 8:34 ` Dmitry A. Kazakov
2012-01-09 8:55 ` Maciej Sobczak
2012-01-09 23:58 ` Georg Bauhaus
2012-01-10 8:47 ` Maciej Sobczak
2012-01-10 10:27 ` Dmitry A. Kazakov
2012-01-10 12:27 ` Georg Bauhaus
2012-01-11 8:54 ` Maciej Sobczak
2012-01-10 21:26 ` Randy Brukardt
2012-02-08 12:23 ` Yannick Duchêne (Hibou57)
2012-02-08 12:39 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox