comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@organon.com (Jon S Anthony)
Subject: Re: access variable Q:
Date: 1996/06/18
Date: 1996-06-18T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96Jun18131801@organon.com> (raw)
In-Reply-To: 31C43F54.74E62073@jinx.sckans.edu


In article <31C43F54.74E62073@jinx.sckans.edu> David Morton <dmorton@jinx.sckans.edu> writes:


> How do I do the following in Ada?
> 
> int *ptr;
> int i;
> 
> ptr = &i;

  i : aliased integer;

  type int_ptr is access all integer;
  ptr: int_ptr := i'access;


> I know how to do dynamic stuff with an access pointer,
> but I can't read anything clear in the RM
> about accessing a static variable...

The Rationale has a pretty nice transparent write up on this in 3.7.1.


> for instance, I have a record that I
> want to have access variables  access some of the elements:
> 
> type int_ptr is access integer;
> type foo is record
> 	a, b, c : integer;
> end record;
> 
> bar : foo;
> 
> a_ptr := ??????  -- how do I make this point at bar.a  ????

type int_ptr is access all integer; -- you need the "all"
type foo is record
    a : aliased integer; -- you need the "aliased"
    b : integer;
    c : integer;
end record;

bar : foo;

a_ptr: int_ptr := bar.a'access;


/Jon
-- 
Jon Anthony
Organon Motives, Inc.
1 Williston Road, Suite 4
Belmont, MA 02178

617.484.3383
jsa@organon.com





  parent reply	other threads:[~1996-06-18  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-16  0:00 access variable Q: David Morton
1996-06-16  0:00 ` Robert Dewar
1996-06-17  0:00 ` David Morton
1996-06-18  0:00 ` Jon S Anthony [this message]
1996-06-19  0:00 ` John Herro
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox