comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: "out" or "access"
Date: 1998/10/30
Date: 1998-10-30T00:00:00+00:00	[thread overview]
Message-ID: <wccpvb9vh0k.fsf@world.std.com> (raw)
In-Reply-To: m3zpaeqq56.fsf@mheaney.ni.net

Matthew Heaney <matthew_heaney@acm.org> writes:

> The RM also recommends that implementations "deliver a useful result"
> when you take the O'Address of a by-reference type (tagged types,
> limited types) passed as a subprogram parameter.  That's why
> Sys.Addr_To_Acc_Conv can be used to work around this problem.

I don't understand why you want to use 'Address at all.
My earlier suggestion was to use 'Unchecked_Access.
It has the same problem with possible dangling references,
but at least it doesn't throw type checking completely out
the window, as 'Address does.

>    type My_Iterator is 
>       new Iterator with record
>          Stack : Conv.Object_Pointer;
                   ^^^^^^^^^^^^^^^^^^^
Say My_Stack_Ptr, which is declared "access constant My_Stack", and then...
>          Index : <some index type>;
>       end record;
> 
>    function Initialize (S : My_Stack) return Iterator'Class is
>    begin
>       return My_Iterator'(To_Pointer (S'Address), S.Top);

       return My_Iterator'(S'Unchecked_Access, S.Top);

>    end;

By the way, have you considered making the iterators limited,
and initializing them with a discriminant that points to the
Stack (or whatever is being iterated)?

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




  reply	other threads:[~1998-10-30  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-21  0:00 "out" or "access" =:-) Vincent
1998-10-21  0:00 ` dennison
1998-10-21  0:00 ` Tucker Taft
1998-10-22  0:00   ` Pascal Obry
1998-10-29  0:00     ` Robert A Duff
1998-10-29  0:00       ` Matthew Heaney
1998-10-29  0:00         ` Robert A Duff
1998-10-30  0:00           ` dennison
1998-10-30  0:00             ` Matthew Heaney
1998-10-30  0:00               ` Robert A Duff [this message]
1998-10-31  0:00                 ` dewar
1998-10-31  0:00                   ` Matthew Heaney
1998-10-31  0:00                 ` Matthew Heaney
1998-11-01  0:00                   ` Robert A Duff
1998-11-01  0:00                     ` Matthew Heaney
1998-11-01  0:00                       ` Robert A Duff
1998-11-02  0:00                         ` Matthew Heaney
1998-11-03  0:00                           ` Simon Wright
1998-11-16  0:00                             ` Matthew Heaney
1998-10-21  0:00 ` Jeff Carter
1998-10-21  0:00   ` Pat Rogers
1998-10-21  0:00     ` Martin C. Carlisle
1998-10-22  0:00       ` Pat Rogers
1998-10-22  0:00     ` Robert A Duff
replies disabled

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