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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,dbbbb21ed7f581b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!de-l.enfer-du-nord.net!gegeweb.org!aioe.org!nospam From: "John B. Matthews" Newsgroups: comp.lang.ada Subject: Re: Operation can be dispatching in only one type Date: Wed, 02 Dec 2009 06:18:40 -0500 Organization: The Wasteland Message-ID: References: <025105f2-5571-400e-a66f-ef1c3dc9ef32@g27g2000yqn.googlegroups.com> <0f177771-381e-493b-92bb-28419dfbe4e6@k19g2000yqc.googlegroups.com> <1nbcfi99y0fkg.1h5ox2lj73okx$.dlg@40tude.net> <59acf311-3a4a-4eda-95a3-22272842305e@m16g2000yqc.googlegroups.com> <4b150869$0$6732$9b4e6d93@newsspool2.arcor-online.net> <18vlg095bomhd.8bp1o9yysctg$.dlg@40tude.net> <4b152ffe$0$7615$9b4e6d93@newsspool1.arcor-online.net> <19nhib6rmun1x$.13vgcbhlh0og9$.dlg@40tude.net> <4b1557d0$0$7623$9b4e6d93@newsspool1.arcor-online.net> <4b15b59b$0$7632$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: LQJtZWzu+iKlBROuDg+IUg.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.0 Cancel-Lock: sha1:Vs0TK27xeK63ZljTc4JWwHsA0WM= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news1.google.com comp.lang.ada:8281 Date: 2009-12-02T06:18:40-05:00 List-Id: In article <4b15b59b$0$7632$9b4e6d93@newsspool1.arcor-online.net>, Georg Bauhaus wrote: [...] > The Java rule I had been thinking of starts from less emphasis on > what the default initial (Ada) value of a (local) variable might be, > given current Ada rules. Rather, in the sequence of statements below > the compiler would just not accept the reference to the .Rim_Color > component of Spare. The meaning of the declaration Spare : Tire > needs to be understood as slightly changed, to exclude (or ignore) > default initialization. > > Spare : Tire; > begin > -- Here, whatever Spare is, or whichever side effects its > -- declaration may have, it is not used between > -- its declaration and the line following the if statement. > -- Therefore, we are free to think of it as something > -- or as nothing, or as something to become a Tire when > -- necessary. A virtual object, perhaps. (Otherwise, use > -- syntax to indicate that there is something important > -- going on in default init; or, for compatibility, when > -- nothing important is going on.) > > if Some_Condition then > Spare := Make_a_Tire; > end if; > Its_Color := Spare.Rim_Color; -- illegal > > > A simple rule would now be a copy of the Java rule which is > quoted below. Just assume that Spare has no value. > Just like the last line is not accepted by SPARK or > by Java (the corresponding Java source line). The warning > which some Ada compilers will issue (that Spare may not have > been assigned a value) is then turned into an error. Ah, I see. Nothing in the present Ada specification _requires_ such a warning. > As might be expected in Ada, some syntax might be in > order to say that default initialization does > provide an initial value that warrants the safe use of the > variable after the if statement (or is needed for its > side effects, but this is another story, I guess). > > Another case is when a declared variable is used in > a declaration of another variable following it, > > Spare : Tire; > Another : Tire := Spare; -- might become illegal > begin > ... > > Illegal unless it is specified that Spare does have > a valid Tire value. Or, oddly, that Another "inherits" the > unknown state of Spare WRT being initialized or not. > > This is the Java rule I had in mind. I found it thanks to the > link you have supplied: > "A Java compiler must carry out a specific conservative flow > analysis to make sure that, for every access of a local > variable or blank final field f, f is definitely assigned > before the access; otherwise a compile-time error must occur." I can see the appeal of adding such an analysis to Ada. -- John B. Matthews trashgod at gmail dot com