From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Assignment access type with discriminants
Date: Thu, 23 Mar 2023 12:51:03 +0100 [thread overview]
Message-ID: <tvhef6$1237n$1@dont-email.me> (raw)
In-Reply-To: <tvf294$ldho$1@dont-email.me>
On 2023-03-22 15:10, G.B. wrote:
> Some experiments point at the general access type.
>
> type Foo_Ptr is access Foo; -- sans `all`
> X : Foo;
> P : Foo_Ptr := new Foo;
> type Foo1 is new Foo_Ptr (K => F1);
> begin
> X := (F2, 1.0); -- OK
> P.all := (F1, 3); -- _no_ Error!
> Foo1 (P).all := (F1, 3);
> end Test;
You get no error because you do not change the discriminant. Change your
code to:
P.all := (F2, 1.0); -- Error!
> (Doesn't rejection for general access types seem reasonable
> if assignment would otherwise require adjusting the storage
> layout of a variable, including all access paths to components?
> Just guessing.)
I guess that an implementation must allocate memory for any value unless
you constraint the discriminants in a subtype. But I am not a language
lawyer to judge.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2023-03-23 11:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 9:19 Assignment access type with discriminants Dmitry A. Kazakov
2023-03-22 9:31 ` Björn Lundin
2023-03-22 14:10 ` G.B.
2023-03-23 11:51 ` Dmitry A. Kazakov [this message]
2023-03-23 16:53 ` AdaMagica
2023-03-23 18:09 ` Niklas Holsti
2023-03-23 17:04 ` J-P. Rosen
2023-03-23 18:55 ` Niklas Holsti
2023-03-23 19:53 ` Dmitry A. Kazakov
2023-03-24 9:41 ` J-P. Rosen
2023-03-25 8:51 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox