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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no 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!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Introductory Ada Programming Book Date: Wed, 4 Jan 2017 15:47:03 -0600 Organization: JSA Research & Innovation Message-ID: References: <87r34j39u6.fsf@nightsong.com> <7643d59e-061f-42df-adda-9322608f127b@googlegroups.com> <75f2482a-a94b-4820-b2b1-990010103709@googlegroups.com> <4c5dfbe4-7987-48d4-8afc-817a8c134095@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1483566424 15200 24.196.82.226 (4 Jan 2017 21:47:04 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 4 Jan 2017 21:47:04 +0000 (UTC) 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.6157 Xref: news.eternal-september.org comp.lang.ada:33055 Date: 2017-01-04T15:47:03-06:00 List-Id: "Shark8" wrote in message news:4c5dfbe4-7987-48d4-8afc-817a8c134095@googlegroups.com... On Wednesday, January 4, 2017 at 6:45:29 AM UTC-7, raph....@gmail.com wrote: > Le mercredi 4 janvier 2017 13:49:18 UTC+1, Dmitry A. Kazakov a écrit : >> > >> > declare >> > I : Integer := 1; -- OK >> > J : Integer; -- Error: not initialized >> > K : Integer := <>; -- OK: uninitialized, I know what I am doing >> > >> >> Or do it Swift's way and use flow analysis to make use of an >> uninitialized variable >> a compile time error. Meh. I guess it's complicated enough as it is to >> implement >> an Ada compiler :) > >Well, there are certain times where you *want*/*need* non-initialized >variables; > it's usually at [operating] system-level, but it does exist. (A good > example would > me memory-mapped I/O ports, where your 'initialization' would > automatically > send something down the I/O port when you might need to send nothing.) Right. It also might happen if the initialization is very complex and interrelated with initializing other variables. Forcing an initialization just to make the compiler happy would be confusing and potentially expensive (if the item is large). I agree with Dmitry. Indeed, I tried hard in Ada 2005 to get (<>) to be an aggregate usable to default initialize for any type, with the intent to combine that with a restriction to essentially allow projects to change Ada to the rule Dmitry suggested. Unfortunately, various technical issues with private types made that much harder than originally thought, and the idea was dropped late in the Ada 2005 work. The problem with requiring flow analysis in a language rule is that it requires lengthy specifications of exactly what flow analysis is required for this check, assuming that portability between implementations is important (and that surely is for Ada). Every compiler does some flow analysis, but each it likely to do it differently, in different compiler phases, and having program legality be implementation-defined in that way is a guaranteed way to have code that cannot be moved to a different implementation. (Exception contracts have a similar problem.) Randy. The problem with using