From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Possible to recover default value of scalar type? Date: Tue, 15 Dec 2020 10:07:02 +0100 Organization: Adalog Message-ID: References: <0c0ddb8e-6a82-473d-8143-f4076242f520n@googlegroups.com> <86r1ntntb3.fsf@stephe-leake.org> <0ded905f-94ac-4470-936c-7f1cb19ac798n@googlegroups.com> <82e629ea-bd59-417a-9185-dd6094e396c1n@googlegroups.com> <570e9d30-0b33-45f0-a9fe-163cc810a770n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 15 Dec 2020 09:07:02 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="1e512d742c750d66e09f3557512008e9"; logging-data="12503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jSooqqDT0LWRPKLxaTf2V" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 Cancel-Lock: sha1:kds288c1TDcWGzsPk8im0F3T8sI= In-Reply-To: Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:60864 List-Id: Le 15/12/2020 à 08:23, Dmitry A. Kazakov a écrit : >> Not applicable if your variable is used in a loop: >> >>     V : Integer; >> begin >>     loop >>        Get (V); >>        exit when V =0; >>        -- do something with V >>     end loop; >> >> Clearly, initializing V makes no sense. > >    loop >       declare >          V : constant Integer := Get; >       begin >          exit when V = 0; >          -- do something with V >       end; >    end loop; > Well, you can push anything in a function, but it's not always clear/readable/simpler... > It is related to another long standing issue with returning values > (multiple values) from functions and functions with in out parameters > (resolved recently). > > Returning to Simon's argument about detecting uninitialized variables. > It would not apply to your example. > >    V : Integer := <>;  -- Invented syntax for explicit lack of >                        -- initialization > begin >    loop >       Get (V); >       exit when V = 0; >       -- do something with V >    end loop; That would make more sense: make initialization required, and say so if you don't care. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr