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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2f84446733b06aca X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: Converting C++ class to Ada Date: 1996/12/21 Message-ID: #1/1 X-Deja-AN: 205221190 sender: news@organon.com (news) references: <32ADF183.7195@lmtas.lmco.com> organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-12-21T00:00:00+00:00 List-Id: In article <32BAD007.648F@watson.ibm.com> "Norman H. Cohen" writes: > Jon S Anthony wrote: > > > In article mheaney@ni.net (Matthew > > Heaney) writes: > > > ... > > > I thought that access discriminants (and parameters) without an explicit > > > type raise Program_Error when you pass "null" as the value? > > > > CE is raised if a null value is passed to an access _parameter_. I > > have never seen anything indicating that CE (or PE) is raised if a > > null value is given for the value of an access _discriminant_. A good > > thing IMO on both counts. See in particular 11.5(11) > > > > Of course, given a recent little discussion on the GNAT chat list I > > could simply have not found it yet... :-) But really, this point seems > > pretty clear! Criminey. This one is yet another example of unnecessary RM opacity after all... :-( > A null access discriminant is a run-time error. > > 11.5 is just a list of the language-defined checks, together with an > informal description of when the checks occur. The definitive rules > about when a check is performed will be found in the "Dynamic Semantics" > sections describing the execution, evaluation, or elaboration of the > relevant constructs. Yes, I actually looked around in the relevant places under this very heading. > Constraint_Error--see 4.6)...." Hidden in 4.6(49) is the rule, "If the > target type is an anonymous access type, a check is made that the value > of the operand is not null...." (4.6(57) states that the exception > raised when this check fails is Constraint_Error. The rule in RM > 4.6(49) can be found using the index entry for "Access check".) Even found this, but being listed under "Type Conversions" I mistakenly did not think that it applied to the discriminant case since that case was not also called out in 11.5(11) along with the parameter case. But actually, on a moments reflection this is the general rule and must cover the parameter case as well (passing null like anything else requires a conversion to the anonymous access type of the formal and there you are). This being the case it is highly unfortunate that the discriminant case was not also called out in 11.5(11) or that the parameter case was not _removed_ from 11.5(11). As it sits the thing is close to being inconsistent (at worst) or highly misleading (at best). Ugh! /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com