From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Unexpected discriminant check failure involving access types Date: Mon, 10 Aug 2015 14:00:56 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <55C8B334.2010102@spam.spam> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1439233258 1651 24.196.82.226 (10 Aug 2015 19:00:58 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 10 Aug 2015 19:00:58 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:27409 Date: 2015-08-10T14:00:56-05:00 List-Id: "Markus Schöpflin" 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.