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!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Uninitialized out parameters. Date: Wed, 6 Apr 2016 23:22:22 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <3be79ab3-ebc7-4169-9713-d50349662403@googlegroups.com> <70a76f87-51a9-4e77-9fa0-79714f9c0ba7@googlegroups.com> NNTP-Posting-Host: LMk7+sG0YqgPmReI4fVkAA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:30025 Date: 2016-04-06T23:22:22+02:00 List-Id: On 2016-04-06 23:01, Randy Brukardt wrote: > I said: >> It *seems* like checks like the one Ahlan is suggesting are a good idea, >> until you trip over one. (The check in Ada that every function have at >> least one return is a similar idea, which causes no end of trouble.) > > On top of that, exactly what would the check be? Which of the following > ought to be illegal? > > procedure Foo1 (Obj : out Positive) is null; > > procedure Foo2 (Obj : out Positive) is > begin > null; > end Foo2; > > Debug : constant Boolean := False; > procedure Foo3 (Obj : out Positive) is > begin > if Debug then > Put_Line ("Foo3 called"); > end if; > end Foo3; > > Foo1 and Foo2 are semantically identical (Foo1 is in fact defined in terms > of Foo2). But it is clearly a lot harder for an Ada compiler to detect Foo2 > compared to Foo1 (and changing between them is common). Having different > legality for Foo1 and Foo2 would be annoying at best. > > Obviously, detecting Foo3 is even harder for a compiler, but again, > semantically it is identical to Foo2. So where do you stop? And why? Simple, the rules must be same as ones for the function return, which are exemplarily annoying, nevertheless considered OK. To the question "where to stop" there is a simple rule: no false negatives Thus is you want to stop at Foo3, the outcome is "illegal" regardless Debug value. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de