comp.lang.ada
 help / color / mirror / Atom feed
* Access types and classwide programming
@ 2001-09-15 19:36 chris.danx
  2001-09-15 20:28 ` chris.danx
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: chris.danx @ 2001-09-15 19:36 UTC (permalink / raw)


Hi,

Suppose that there is a package X , with the following body

package X is

    type xxx is tagged private;
    type xxx_access is access all xxx;
    type xxx_class_access is access all xxx'class;

    procedure init (s : out xxx);

    function get_something (sc : in xxx_class_access)
    return integer;

private
    ...

end X;

Now you want to test it, but there's a probem.
I've tried

with x; use x;
with ada.integer_text_io; use ada.integer_text_io;

procedure test_x is

    temp : aliased xxx;

begin
    init (temp);    -- this is ok!

    put( get_something(temp'access)); -- error 1 here
end x;


error 1 is "non-local pointer cannot point to local object"

I've tried lot's of different ways, (temp wasn't aliased the first run and
this lead to an error too).

What I want to do is to have a variable of type xxx and to pass it to
get_something and to init.

I'm probably not explaining this properly, hang on...


Suppose you have a tagged type ttype, and need an access type to ttype and
it's class.

type ttype is tagged ...;
type ttype_access is access all ttype;
type ttype_caccess is access all ttype;

How do you

a) get "access" to a variable of ttype?
b) create a new instance of a ttype which is pointed to by a variable of
type ttype_caccess?

I'm still not explaining it proper, am I?  I'm confused.


This is for a program which *in future* will use address to access
conversions (for hardware programming), so it has to be access types.  It's
not neccessary for it to use address to access conversions as no hardware
access is necessary at this point but it will do in the future.

Thanks,
Chris





^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2001-09-19  7:39 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-15 19:36 Access types and classwide programming chris.danx
2001-09-15 20:28 ` chris.danx
2001-09-15 23:42 ` [Different Topic] Endianess? chris.danx
2001-09-16  6:22   ` Jeffrey Carter
2001-09-17  7:37   ` Juanma Barranquero
2001-09-17  7:53     ` Assigning the value of a deferred constant? Juanma Barranquero
2001-09-17 14:04       ` Ted Dennison
2001-09-17 14:36         ` Juanma Barranquero
2001-09-17 17:36           ` tmoran
2001-09-18  8:16             ` Juanma Barranquero
2001-09-18 18:40         ` Richard Riehle
2001-09-19  2:07           ` Vincent Marciante
2001-09-19  7:39           ` Juanma Barranquero
2001-09-16  6:19 ` Access types and classwide programming Jeffrey Carter
2001-09-16 13:37   ` chris.danx
2001-09-16 16:49     ` Jeffrey Carter
2001-09-16 18:24       ` David C. Hoos, Sr.
2001-09-17  6:15         ` Jeffrey Carter
2001-09-17  4:57     ` tmoran
2001-09-17 14:16       ` Ted Dennison
2001-09-16  9:32 ` tmoran
2001-09-17  9:41 ` John McCabe

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