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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,86ec22e070e319c0 X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: How do I get this to work?? Date: 1999/01/08 Message-ID: #1/1 X-Deja-AN: 430101991 X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 References: <76s0dp$1v4$1@nntp3.uunet.ca> <76tbvv$ba5$1@nntp3.uunet.ca> <770ifd$qui$1@goblin.uunet.ca> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 915778941 nnrp-11:19238 NO-IDENT pogner.demon.co.uk:158.152.70.98 Organization: At Home Newsgroups: comp.lang.ada Date: 1999-01-08T00:00:00+00:00 List-Id: Stephen Leake writes: > I agree with the other comments here; the bad taste is from not > knowing what will happen to the pointer when you pass it to C. That's > why it is "unchecked". Not just to C! for example, in the Booch Components, I have procedure Create_Arc (G : in out Undirected_Graph; A : in out Undirected_Arc'Class; I : Arc_Item; First : in out Undirected_Vertex'Class; Second : in out Undirected_Vertex'Class) is begin Clear (A); A.Rep := new Arc_Node'(Ada.Finalization.Controlled with Item => I, Enclosing => G'Unchecked_Access, -- <<<<<<<<<<<<<<<< From => First.Rep, To => Second.Rep, Next_Incoming => null, Next_Outgoing => null, Count => 1); and the Unchecked_Access is needed because (I suppose) you can't tell at compile time what the scope of the actual for G is. It would certainly be possible (though unnatural) to use this code with the scope of the actual G being less than that of the actual A .. hmm, I guess there's a warning-to-users needed there ..