comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: "out" or "access"
Date: 1998/10/31
Date: 1998-10-31T00:00:00+00:00	[thread overview]
Message-ID: <m3ww5hrbmr.fsf@mheaney.ni.net> (raw)
In-Reply-To: wccpvb9vh0k.fsf@world.std.com

Robert A Duff <bobduff@world.std.com> writes:

> 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...

You are correct.  However, the library I'm building has one iterator
type, that can be used to both query and modify objects in the
collection.  The representation of the iterator must therefore include
an access-to-variable access type.

(Actually, I could do it the other way around: implement the iterator
type using an access-to-constant access type, and use addr-to-acc-conv
inside the one operation that modifies state.  Hmmm...)

So perhaps I'm going beyond what even access constant params buy you.
Maybe my real problem is how to "cast away const."  It would be hip if
the language provided a way to do that explicitly, analogous to
something like Unchecked_Conversion.

BTW: does the language define --or give implementation advice-- on what
the effect of unchecked conversion from access-to-constant to
access-to-variable is?  Or is it the intention of the designers that you
never try to do that?

Real programmers --like me-- are occasionally going to need to cast away
const.  The language designers should state explictly 1) that you
shouldn't do that, or 2) that it's OK to do it, and here's how.

If you don't say, then I'm going to do it _some_ way, perhaps using a
technique you didn't intend.  Just tell me what your specific intent is.

> 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)?

Oh yes, but this doesn't meet my needs, because you need to call a
dispatching operation ("factory method") that returns an iterator of a
class-wide type.  Class-wide types are indefinate, and therefore require
initialization during object declaration, which isn't possible if the
type is limited.




  reply	other threads:[~1998-10-31  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 ` 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
1998-10-31  0:00                 ` Matthew Heaney [this message]
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-31  0:00                 ` dewar
1998-10-31  0:00                   ` Matthew Heaney
1998-10-21  0:00 ` dennison
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