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,92d7ad88838233dd X-Google-Attributes: gid103376,public From: matthew_heaney@acm.org (Matthew Heaney) Subject: Re: Q:Assigning address of variable to pointer ? Date: 1998/04/16 Message-ID: #1/1 X-Deja-AN: 344592286 Content-Transfer-Encoding: 8bit References: Content-Type: text/plain; charset=ISO-8859-1 Organization: Network Intensive Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-04-16T00:00:00+00:00 List-Id: In article , Margarit Nickolov wrote: > type element is record > ... > end record; > > type p_element is access element; > > e1: element; > p_e1: p_element := null; > > begin > e1 := some_value; > -- now, how to point p_e1 to the variable e1 ? > p_e1.all := e1; -- is that correct ? > -- I have got exception RANGE_ERROR. > end; > > > I just want to assign 'address' of some dynamic/static allocated memory to >'pointer variable'. You have to declare the object you want to point to as aliased - but declare a general access type: type p_element is access all element; declare e1 : aliased element; p_e1 : p_element; begin e1 := ; p_e1 := e1'access; end; Of course, you could always put the object on the heap: declare e1 : element; p_e1 : p_element; begin e1 := ; p_e1 := new element; p_e1.all := e1; end; And we can combine steps: declare p_e1 : constant p_element := new element'(); begin null; end;