comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Unexpected discriminant check failure involving access types
Date: Mon, 10 Aug 2015 14:00:56 -0500
Date: 2015-08-10T14:00:56-05:00	[thread overview]
Message-ID: <mqasd9$1jj$1@loke.gir.dk> (raw)
In-Reply-To: 55C8B334.2010102@spam.spam

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]

"Markus Schöpflin" <no.spam@spam.spam> wrote in message 
news:55C8B334.2010102@spam.spam...
...
> I still don't get it: I would have expected the objects FOO and
> FOO_PTR.all to be identical in behaviour.

You would have been wrong.

>Why is "new RECORD_T" creating a
> constrained record and just using "RECORD_T" not?

Because that's what Ada 83 specified and it is incompatible to change it. 
It's known to be stupid, but even a talented a designer as Jean Ichbiah was 
will make some mistakes.

I'm not certain as to why Ada 83 adopted that model, probably you'd have to 
look in the Rationale.

Anyway, every Ada programmer knows (or soon will find out) that one has to 
make mutable discriminated records components (never a top-level object) 
when allocated. There are a lot of records like:

     type Record_Wrapper_T is record
          C : Record_T;
     end record;

(Note that this is why the restriction is stupid, one can easily cause 
whatever complications were supposedly being eliminated by using a 
component.)

Anyway, the rule in question is 4.8(6/3), and the technical term is 
"constrained by its initial value". It's the same mechanism that is used if 
Record_T had been indefinite (had no default discriminant value).

Note that we created a "hole" in this rule for completions of (constrainted) 
private types, else there was a practical privacy breakage (some assignments 
might fail for no good reason from the clients perspective). That was 
controversal, and its unlikely we'd ever go further.

                                       Randy.




  reply	other threads:[~2015-08-10 19:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10 12:38 Unexpected discriminant check failure involving access types Markus Schöpflin
2015-08-10 13:14 ` Mark Lorenzen
2015-08-10 14:20   ` Markus Schöpflin
2015-08-10 19:00     ` Randy Brukardt [this message]
2015-08-10 14:33 ` Niklas Holsti
2015-08-10 14:56   ` Markus Schöpflin
2015-08-10 19:43     ` Niklas Holsti
replies disabled

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