comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Lundquist <mark@rational.com>
Subject: "cast away const" (was Re: Array of Variant Records Question...)
Date: 1999/09/14
Date: 1999-09-14T00:00:00+00:00	[thread overview]
Message-ID: <37DE871E.4249A231@rational.com> (raw)
In-Reply-To: 37d9a3b7@news1.prserv.net

Matthew Heaney wrote:

> In article <37D96965.81045235@rational.com> , Mark Lundquist
> <mark@rational.com>  wrote:
>
> >> That seems just *too* kludgy to me, and very implemention
> >> dependent, wouldn't it be better to just introduce in out
> >> and out parameters for functions (but we know that one won't
> >> fly ...)
> >>
> >
> > Why would that be necessary, since functions already can have access
> > parameters?  OK, the actual must denote an aliased view...
>
> It's like I said in another post: sometimes you have an operation that is
> publicly in-mode, but privately in-out.
>
> The function Random is declared this way:
>
>   function Random (G : in Generator) return Result_Subtype;
>
> From an abstract point of view, Generator provides a stream of random
> numbers, and function Random simply returns successive values from this
> stream.  The stream is just out there, in the ether, and no modification of
> this stream is required.

At this level of abstraction, something like a self-advancing iterator would
look similar.  It's not that much of a stretch, even though everyone knows that
the iterator must have state and that the state must change when the iterator
advances.  But it's not like you really want to say "extract the value, and oh
by the way update the iterator, too..."  You really just mean, "I'm giving you
the iterator to operate on", i.e., in-mode.

>

> From an implementation point of view, however, invoking the function Random
> changes the state of the Generator.  That's why you need a way to "cast away
> const," to be able to change state of an object whose parameter mode is in.

I've been trying think from your "abstract point of view" about objects whose
type view is limited private.  What exactly can "state" mean from this
perspective?  You don't know about its components, can't assign it, can't test
equality.  Isn't the idea "state" of an opaque object kind of problematic?
Suppose that in the bodies of primitives of types whose partial view is limited
private, an in-mode parameter declared a variable view instead of a constant
view (in other words, if the differentiation of in-mode vs. in-out-mode were
annulled).  A bizzarre idea on the face of it, but -- what would be lost?
(Not that I think this would actually be a good idea...)

Why do we have parameter modes in the first place? It's so that intent is
communicated explicitly, esp. to programmers who are going to code against the
subprogram declaration.  We could have only mode in-out, as is the case in Java
-- then it's this expressiveness that would be lost, but in the case of limited
private types it sort of collapses.

If the language adopted your cast-away-const operation, should it be available
only for types whose partial view is limited private, and then only where the
full view is visible (i.e. in the body?)






  parent reply	other threads:[~1999-09-14  0:00 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-08  0:00 Array of Variant Records Question Bruce Detter
1999-09-08  0:00 ` Thank you Bruce Detter
1999-09-08  0:00   ` Martin C. Carlisle
1999-09-08  0:00 ` Array of Variant Records Question Martin C. Carlisle
1999-09-08  0:00 ` Matthew Heaney
1999-09-08  0:00   ` Mike Silva
1999-09-08  0:00     ` Matthew Heaney
1999-09-09  0:00       ` Robert Dewar
1999-09-09  0:00         ` Matthew Heaney
1999-09-09  0:00           ` Matthew Heaney
1999-09-09  0:00             ` Mark Lundquist
1999-09-09  0:00             ` Robert Dewar
1999-09-09  0:00           ` Robert Dewar
1999-09-09  0:00             ` Matthew Heaney
1999-09-10  0:00               ` Robert Dewar
1999-09-10  0:00                 ` Mark Lundquist
1999-09-10  0:00                   ` Matthew Heaney
1999-09-11  0:00                     ` Jean-Pierre Rosen
1999-09-14  0:00                     ` Mark Lundquist [this message]
     [not found]                     ` <wccd7viiv59.fsf@world.std.com>
1999-09-22  0:00                       ` Robert I. Eachus
     [not found]                       ` <7rrmqd$l89@drn.newsguy.com>
     [not found]                         ` <wcciu59n2uf.fsf@world.std.com>
1999-09-22  0:00                           ` Robert I. Eachus
1999-09-23  0:00                             ` Robert Dewar
1999-09-23  0:00                               ` Robert I. Eachus
1999-09-10  0:00               ` Mark Lundquist
1999-09-10  0:00                 ` Matthew Heaney
1999-09-11  0:00                 ` Robert Dewar
1999-09-11  0:00               ` Richard D Riehle
1999-09-13  0:00                 ` Hyman Rosen
1999-09-14  0:00                 ` Mark Lundquist
     [not found]                   ` <7roohh$s6r@dfw-ixnews7.ix.netcom.com>
     [not found]                     ` <37e01168@news1.prserv.net>
     [not found]                       ` <7rp86o$c6h@dfw-ixnews3.ix.netcom.com>
     [not found]                         ` <37E18CC6.C8D431B@rational.com>
     [not found]                           ` <7rs8bn$s6@dfw-ixnews4.ix.netcom.com>
     [not found]                             ` <wccemfxn15s.fsf@world.std.com>
1999-09-22  0:00                               ` 'constant functions' and access constant params (was Re: Array of Variant Records Question...) Richard D Riehle
     [not found]                             ` <37e2e58c@news1.prserv.net>
1999-09-22  0:00                               ` Richard D Riehle
1999-09-22  0:00                                 ` Matthew Heaney
1999-09-22  0:00                                   ` Richard D Riehle
1999-09-22  0:00                                     ` Matthew Heaney
1999-09-22  0:00                                     ` Matthew Heaney
1999-09-23  0:00                                       ` Vincent Marciante
1999-09-23  0:00                                         ` Matthew Heaney
1999-09-24  0:00                                       ` Robert A Duff
1999-09-25  0:00                                         ` Matthew Heaney
1999-09-27  0:00                                       ` Richard D Riehle
1999-09-27  0:00                                         ` David Kristola
1999-09-27  0:00                                       ` Richard D Riehle
1999-09-23  0:00                                     ` Robert Dewar
1999-09-27  0:00                                       ` Richard D Riehle
1999-09-28  0:00                                         ` Robert Dewar
1999-09-28  0:00                                           ` Richard D Riehle
1999-09-29  0:00                                             ` Robert Dewar
1999-09-29  0:00                                             ` Robert A Duff
1999-09-28  0:00                                         ` Robert Dewar
1999-09-28  0:00                                           ` "Competence" (was: 'constant functions' and access constant params) Ted Dennison
1999-09-28  0:00                                             ` Robert Dewar
1999-09-22  0:00                                 ` 'constant functions' and access constant params (was Re: Array of Variant Records Question...) Mark Lundquist
1999-09-22  0:00                                   ` Mark Lundquist
1999-09-09  0:00             ` Array of Variant Records Question Brian Rogoff
1999-09-13  0:00               ` Matthew Heaney
1999-09-13  0:00                 ` Brian Rogoff
1999-09-14  0:00                   ` Robert Dewar
1999-09-14  0:00                   ` Robert Dewar
1999-09-14  0:00                     ` Brian Rogoff
1999-09-13  0:00                 ` Robert A Duff
1999-09-13  0:00                   ` Matthew Heaney
1999-09-10  0:00             ` Proposed Ada features (was Re: Array of Variant Records Question...) Mark Lundquist
1999-09-10  0:00               ` Matthew Heaney
1999-09-10  0:00                 ` tmoran
1999-09-09  0:00     ` Array of Variant Records Question Nick Roberts
1999-09-09  0:00       ` Tucker Taft
1999-09-10  0:00         ` Nick Roberts
1999-09-09  0:00       ` Robert Dewar
1999-09-08  0:00 ` Ted Dennison
replies disabled

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