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!proxad.net!feeder1-2.proxad.net!usenet-fr.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: Tue, 01 Dec 2009 16:53:48 -0500 Organization: The Wasteland Message-ID: References: <025105f2-5571-400e-a66f-ef1c3dc9ef32@g27g2000yqn.googlegroups.com> <4b091fb9$0$6567$9b4e6d93@newsspool4.arcor-online.net> <1w0q3zxzw79pt$.5z0juiky7kfd$.dlg@40tude.net> <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> 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:fxjRTCGd+TewLoTvnDLMfXEze0c= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: g2news1.google.com comp.lang.ada:8276 Date: 2009-12-01T16:53:48-05:00 List-Id: In article , "Dmitry A. Kazakov" wrote: > On Tue, 01 Dec 2009 18:52:15 +0100, Georg Bauhaus wrote: > > > Dmitry A. Kazakov schrieb: > >> On Tue, 01 Dec 2009 16:02:21 +0100, Georg Bauhaus wrote: [...] > >>> If you feed this to a Java compiler you will see how it is done. > >>> The Java compiler will not accept a reference to a variable's > >>> component when the variable may not have been initialized. > >> > >> I consider this model wrong. It is better not to introduce > >> inappropriate values rather than trying to catch them later. > > > > The Java rule works at compile time. No value is introduced at any > > time during compilation. Nothing to catch. > > Of course there is something to catch. The compiler has to do this. > So the question is at which cost, how many false positives and > negatives it will find? How scalable is this feature for more > elaborated types? If I may amplify on this, the Java compiler rejects the assignment to its_color because it's a local variable, which must have an explicit value before use [1]. Once Tire's constructor completes, the value of spare.rim_color has the default value null [1]. The compiler need only check that its_color has been assigned in the current scope [2]. In Georg Bauhaus' example, the constructor is invoked in a nested scope. In Ada, I get a warning that '"Spare" is read but never assigned.' type Tire_Color is (Black, White); type Tire is record Rim_Color : Tire_Color; end record; Spare : Tire; If I throw in "for Tire_Color use (Black => 1, White => 2)," the implicit initial value [3] of Rim_Color is not valid for Tire_Color. It's "a bounded error to evaluate the value of such an object [4]," and I get CONSTRAINT_ERROR at run-time. The Java compiler doesn't warn that spare.rim_color is null by default; the Ada compiler doesn't warn that Spare.Rim_Color is invalid by default. In either language, I have to either accept the default initial values or specify them. I sense I'm missing something. [1] [2] [2] [3] -- John B. Matthews trashgod at gmail dot com