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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: two questions on allocators Date: Sat, 24 Feb 2018 20:17:30 -0600 Organization: JSA Research & Innovation Message-ID: References: <93229821-ae3d-4e47-91d9-a20ff3c1f1a7@googlegroups.com> Injection-Date: Sun, 25 Feb 2018 02:17:30 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="8972"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:50626 Date: 2018-02-24T20:17:30-06:00 List-Id: "Mehdi Saada" <00120260a@gmail.com> wrote in message news:dfa8abf3-6016-45dc-88de-91f31fac853a@googlegroups.com... >> Finally, the phrase "new not null B" is in error, as you cannot say "new >> not null" in Ada. > Here's a simpler exemple ( I think I mixed up A and B, which made my > statement meaningless): > type A is access INTEGER; > type B is access not null A; > Object_B : B := new A; --- ** > allowed > type A is access INTEGER; > type B is access A; > Object_B : B := new not null A; -- illegal, > but wouldn't that be the same than * ? > Anyway, let's forget it. Naw, let's answer it. Look in the AARM (4.8(2.a/3) [directly under the rule in question]): "Such an uninitialized allocator would necessarily raise Constraint_Error, as the default value is null. Also note that the syntax does not allow a null_exclusion in an initialized allocator, so it makes sense to make the uninitialized case illegal as well." That is, an access value is default-initialized to the null value. So this allocator is just a silly way to write (raise Constraint_Error). Another such silly way is: Object_B : not null B; -- Always raises Constraint_Error. If you're going to be interested at this level of detail, I suggest looking in the AARM, which has various "annotations" explaining rules, and with links to the AIs that generated the rules (if they're new). You can usually figure out the rules this way. The AARM can be found in most of the usual places, in particular on www.ada-auth.org. Randy.