From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Access idiom
Date: Mon, 21 Jan 2008 10:37:42 -0500
Date: 2008-01-21T10:37:42-05:00 [thread overview]
Message-ID: <wccwsq3chq1.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: adad44a1-0519-4333-add6-86936adc7ab1@l1g2000hsa.googlegroups.com
Gene <gene.ressler@gmail.com> writes:
> In concept, what I'd need to do is something like this:
>
> type Node_Ptr_Type is access Node_Type'Class;
>
> procedure Op(P : in Threat_Type; Result : out Node_Ptr_Type) is
> begin
> Result := P'Access; -- identity operation
> end Op;
I'm not sure exactly what you're trying to do,
but the following might be what you want:
type Node_Ptr_Type is access constant Node_Type'Class;
^^^^^^^^
procedure Op(P : in Threat_Type; Result : out Node_Ptr_Type) is
begin
Result := P'Unchecked_Access; -- identity operation
^^^^^^^^^^
end Op;
or:
type Node_Ptr_Type is access all Node_Type'Class;
^^^
procedure Op(P : in out Threat_Type; Result : out Node_Ptr_Type) is
^^^
begin
Result := P'Unchecked_Access; -- identity operation
^^^^^^^^^^
end Op;
'Unchecked_Access can lead to dangling pointers -- you need to make sure
you don't pass nested objects to Op.
- Bob
next prev parent reply other threads:[~2008-01-21 15:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-20 19:57 Access idiom Gene
2008-01-21 1:01 ` Ludovic Brenta
2008-01-21 4:16 ` Gene
2008-01-21 15:37 ` Robert A Duff [this message]
2008-01-22 4:11 ` Randy Brukardt
2008-01-22 4:11 ` Randy Brukardt
2008-01-21 9:05 ` Dmitry A. Kazakov
2008-01-21 18:15 ` Jeffrey R. Carter
2008-01-22 3:56 ` Gene
2008-01-22 5:10 ` Gene
2008-01-22 9:01 ` Dmitry A. Kazakov
2008-01-22 18:47 ` Jeffrey R. Carter
2008-01-22 4:15 ` Randy Brukardt
2008-01-22 4:15 ` Randy Brukardt
-- strict thread matches above, loose matches on Subject: below --
2008-01-21 7:12 Grein, Christoph (Fa. ESG)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox