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!news.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Introductory Ada Programming Book Date: Thu, 5 Jan 2017 00:39:17 +0200 Organization: Tidorum Ltd Message-ID: References: <87r34j39u6.fsf@nightsong.com> <7643d59e-061f-42df-adda-9322608f127b@googlegroups.com> <5b52afcc-120e-41a5-bab2-7f5c6f647cc2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net LQQLZqqFmYQQ5em2PQOnuAqX7jJjVQTsckCKJmXzWwdttWttGY Cancel-Lock: sha1:odKyzNmU41/UqFMdkRarlFRFIJg= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 In-Reply-To: <5b52afcc-120e-41a5-bab2-7f5c6f647cc2@googlegroups.com> Xref: news.eternal-september.org comp.lang.ada:33058 Date: 2017-01-05T00:39:17+02:00 List-Id: On 17-01-04 15:44 , raph.amiard@gmail.com wrote: > I'm in contact with the author so I'll pass any fixes up to him if you don't mind > >> exit when (a == 0) > >> Switch statements must cover all possible input values --- for unbounded >> types like integers, a when others is mandatory. > > I imagine you refer to the use of "unbounded" when refering to the integer type ? That term is one nit that could be picked, but more specifically, it is quite possible to write "case" statements using an integer type without an "others" clause. Very recently, I had occasion to write code like this: X : Int_Type := ... ... case X is when Int_Type_T'First .. -1 => ...; when 0 => ...; when 1 .. Int_Type'Last => ...; end case; >> Oddly, variables are not initialised by default >> (Personal opinion: default initialization is a huge mistake) > > Ok but, besides the "oddly" qualifier, his statement is correct, right ? Except for variables of an access type, or (but perhaps this is not "by default" in his view) of a record type where the components are given initial default values. Requiring default initialisation of all variables, even unused ones, would have a large cost in execution time of any subprogram that uses a local array variable as a buffer for some data. In a resource-constrained real-time application that could be nasty. (For such code, I have once or twice argued with PA/QA people who see a coding rule that says "all variables must be initilised before use" and who think that "X := value" is a "use" of X :-) ). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .