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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,887bac6875d2db34 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Access idiom Date: Mon, 21 Jan 2008 10:37:42 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <87wsq4xa93.fsf@ludovic-brenta.org> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1200929862 31306 192.74.137.71 (21 Jan 2008 15:37:42 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 21 Jan 2008 15:37:42 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:iV949aZFMsWazu7mozl5JUaEiLg= Xref: g2news1.google.com comp.lang.ada:19502 Date: 2008-01-21T10:37:42-05:00 List-Id: Gene 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