comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve Folly" <steve@follysplace.demon.co.uk>
Subject: Re: Access Types
Date: 1999/07/22
Date: 1999-07-22T00:00:00+00:00	[thread overview]
Message-ID: <932674911.9494.0.nnrp-01.c2de848f@news.demon.co.uk> (raw)
In-Reply-To: wcchfmxsy3y.fsf@world.std.com


Robert A Duff <bobduff@world.std.com> wrote in message
news:wcchfmxsy3y.fsf@world.std.com...
> rayoub@wam.umd.edu (Ronald Ayoub) writes:
>
>     type Pointer_To_Const is access constant Integer;
>     type Pointer_To_Var   is access all      Integer;
>
>     X: Pointer_To_Const := ...;
>     Y: Pointer_To_Var := ...;
>
>     Z: constant Pointer_To_Const := ...;
>     W: constant Pointer_To_Var := ...;
>
>     X.all := 1; -- Illegal.
>     X := new Integer'(3); -- OK.
>     Y.all := 1; -- OK.
>     Y := new Integer'(3); -- OK.
>
>     Z.all := 1; -- Illegal;
>     Z := new Integer'(3); -- Illegal.
>     W.all := 1; -- OK.
>     W := new Integer'(3); -- Illegal.
>
>     ...
>
> X and Y are constants; Z and W are variables.
>
> The objects Y and W point to are variables.
> The objects X and Z point to might be constant or variable,
> but they're read-only via X.all and Z.all.
>
> - Bob
> --
> Change robert to bob to get my real email address.  Sorry.

That makes perfect sense for declared variables. But what about subprogram
access type parameters.
For example, you can have...

    function Foo(Bar : access Object) return Boolean;

Which means the function takes an access to an Object variable.
The function is free to change the value of the variable that Bar 'points'
to.

What seems to be missing is something along the lines of...

    function Foo(Bar : access constant Object) return Boolean;

Which would imply that the function cannot change the variable the Bar
points to.

Why is this not included in the language definition. Is there an
alternative?



--
Regards,
Steve Folly -  Y2K compliant since 32nd Februark 1998
http://www.follysplace.demon.co.uk
donationsto:myaccount@mybank.co.uk






  reply	other threads:[~1999-07-22  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-15  0:00 Access Types Ronald Ayoub
1999-07-21  0:00 ` Robert A Duff
1999-07-22  0:00   ` Steve Folly [this message]
1999-07-23  0:00     ` Tucker Taft
  -- strict thread matches above, loose matches on Subject: below --
2007-07-01  0:39 access types Brian May
2007-07-01  1:54 ` Robert A Duff
2007-07-01  7:52   ` Dmitry A. Kazakov
2007-07-01 14:57     ` Robert A Duff
2007-07-01 19:41       ` Dmitry A. Kazakov
2007-07-02  0:12         ` Robert A Duff
2007-07-02  8:06           ` Dmitry A. Kazakov
2007-07-02 15:37       ` Adam Beneschan
1998-05-27  0:00 Access types jsanchor
1998-05-28  0:00 ` Jerry van Dijk
1998-05-29  0:00   ` jsanchor
1998-05-30  0:00     ` Jerry van Dijk
replies disabled

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