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,aa7b0448abeecbba X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: How to print Task_ID type? (GNAT SunOS) Date: 1996/04/05 Message-ID: #1/1 X-Deja-AN: 145959090 references: <316308F0.6375@ee.ubc.ca> <31642F61.1D2B@ee.ubc.ca> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-04-05T00:00:00+00:00 List-Id: Keith said "Another possibility is something like this: declare P: Some_Access_Type := Some_Value; package SSE renames System.Storage_Elements; begin if P = null then Put_Line("P = null"); else Put_Line("P = " & SSE.Integer_Address'Image (SSE.To_Integer(P.all'Address))); end if; end; Note, however, that the value stored in an access object isn't necessarily the address of the designated object. It could include or point to a descriptor, among many other possibilities." The method is fine, the test for null is appropriate (I missed that in my message before!) The caution is probably unnecessary, I think you will find that even in implementations where descriptors etc are used, that 'Address is likely to point to the data. Remember that X.all is the value of the type, and 'Address will normally point to this data. You could make doubly sure in the only case where there even conceivably could be trouble (arrays), by using x.all(x'first)'address but at this stage, this is getting a bit junky, so even though it is a bit more complexity, it is probably ceaner to instantiate address_to_access conversions to get the adress value. I tink in GNAT we wlil make 'Img work for pointers, why not? Img is designed to be helpful in debugging, and this would be helful eventually we would like 'Img to work for composite types as well).