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!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Introductory Ada Programming Book Date: Thu, 5 Jan 2017 07:36:46 +0100 Organization: A noiseless patient Spider 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 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 5 Jan 2017 06:35:20 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="02e545adf3b169668bfe873c5a0859dd"; logging-data="27795"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Nqh0Si6KRy3TeL1W5XKjp" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 In-Reply-To: <5b52afcc-120e-41a5-bab2-7f5c6f647cc2@googlegroups.com> Cancel-Lock: sha1:t+sdUEogPVX+tu6z85bft0uVpKE= Xref: news.eternal-september.org comp.lang.ada:33063 Date: 2017-01-05T07:36:46+01:00 List-Id: Le 04/01/2017 à 14:44, raph.amiard@gmail.com a écrit : > I'm in contact with the author so I'll pass any fixes up to him if you don't mind Well, I suggested help from the community at large because currently I don't have the time to make an extensive review. Otherwise, I'd write to him myself... Some have already responded; my $0.02 >> 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 ? > Asking for automatic initialization comes generally from people using the C like languages, who automatically think of 0 as the initial value. A truely magical value, meaning number 0, false, string termination, etc. It makes no sense for Ada, where types may not include 0 as an allowed value. You can even have types with no value at all; what would the initial value be? But the issue is worth than that. A program that does not initialize a variable before using it has a bug. If the program works because the compiler provided a default value that happened to have an appropriate value, it's a buggy program that works by chance. In the safety critical world, we don't want programs that work by chance; we want programs without bugs. That's why the only acceptable initial value is an invalid value (as provided by Initialize_Scalars), because it maximizes the probability of catching the bug early. >> Ada is, alas, a one-pass language, so things need to be prototyped if >> you're going to refer to them before they're defined. > > This is generally true, and the areas of the language where it's not (aspects) are full of gotchas. While it's not always true, my feeling is that there *was* a strong push to keep Ada compilable by a one pass compiler (which GNAT is, in broad strokes). > I don't think that one pass was ever a requirement for Ada. Claiming that some things are "unfortunately" the way they are to make compilers naively simpler sends a wrong message, and is unfair to the huge work performed by compilers. -- 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