From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: How to pass around access types to interfaces?
Date: Fri, 24 Oct 2008 15:24:50 +0300
Date: 2008-10-24T15:24:50+03:00 [thread overview]
Message-ID: <4901be81$0$23607$4f793bc4@news.tdc.fi> (raw)
In-Reply-To: <c5772601-5fc5-4f2c-a75d-241accf9072d@k30g2000hse.googlegroups.com>
Sven wrote:
> I'm learning Ada and I've run into a big problem with passing around
> access types to interfaces. I guess I just don't know all the
> subtleties of access types, I'm used to C/C++ pointers. I didn't find
> anything helpful on the net or in the Ada Reference Manual.
>
> I'm trying to get this code to run:
>
> in some package:
> type My_Interface is interface;
> type My_Interface_Access is access all My_Interface'Class;
>
> procedure Do_Something( Item : in out Some_Object; With :
> My_Interface_Access );
>
> in main program:
> type Concrete_Type is new My_Interface with ...;
I assume this type declaration is in the main *procedure*. This
means that the type has a local scope and life, which prevents
converting its values to a more long-lived access type. Try
declaring Concrete_Type in a package; that makes it live as long as
the whole program, and should allow such conversions.
HTH,
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2008-10-24 12:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-24 11:45 How to pass around access types to interfaces? Sven
2008-10-24 12:24 ` Niklas Holsti [this message]
2008-10-24 12:49 ` Sven
2008-10-24 13:55 ` Ludovic Brenta
2008-10-24 21:32 ` sjw
2008-10-25 8:54 ` Sven
2008-10-25 15:43 ` Martin Krischik
2008-10-25 22:15 ` Robert A Duff
2008-10-26 8:02 ` Dmitry A. Kazakov
2008-10-26 15:50 ` Martin Krischik
2008-10-28 13:41 ` Maciej Sobczak
2008-10-29 14:15 ` Martin Krischik
2008-10-31 13:38 ` Maciej Sobczak
2008-10-31 14:46 ` Dmitry A. Kazakov
2008-10-29 12:42 ` Sven
2008-10-29 13:17 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox