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: a07f3367d7,9506bdc34331969a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!news-in-02.newsfeed.easynews.com!easynews!core-easynews-01!easynews.com!en-nntp-09.dc1.easynews.com.POSTED!not-for-mail From: Rob Solomon Newsgroups: comp.lang.ada Subject: Re: put of access type Message-ID: <8sho8596j3qnja38id9ipejk0opkcn5b5m@4ax.com> References: X-Newsreader: Forte Agent 4.2/32.1118 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@easynews.com Organization: Forte Inc. http://www.forteinc.com/apn/ X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. Date: Wed, 19 Aug 2009 15:00:46 -0400 Xref: g2news1.google.com comp.lang.ada:6906 Date: 2009-08-19T15:00:46-04:00 List-Id: >> I would like to output a pointer to the screen. (I am just learning >> Ada). >> >> How do I put(Any_Access_Type) > >You probably meant the address of the pointed object. Here you go. Let Ptr >be a pointer to some object > >(with System.Storage_Elements; use System.Storage_Elements;) > > Integer_Address'Image (To_Integer (Ptr.all'Address))); > >Ptr.all'Address is the address of the object. To_Integer converts the >address to a plain integer type (Integer_Address defined in >System.Storage_Elements). This type can be output as any other. I am trying to understand this. Back when I learned Modula-2, I learned that pointer types are assignment compatible with System.Address and I understand them as being the same thing. They differ in context, not value. I see that access types are being used the same as pointer types, but if I understand correctly, are actually quite different. But I don't understand how. ie, how are access types and pointers different? What is the difference between integer_address and address? I need help with this code: procedure adr is c: integer; x: aliased integer; p1, p2 : access integer; str : string (1..255); Begin p1 := x'access; p2 := p1; str := integer_address'image(to_integer(p1.all'address)); c := integer(to_integer(p2.all'address)); some put statements end adr; This compiles w/ GNAT under Ubuntu 9.04, but I am getting constraint_error, range check failed. I don't understand why