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!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 02 Dec 2009 02:13:14 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.4pre) Gecko/20090915 Thunderbird/3.0b4 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Operation can be dispatching in only one type 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4b15bf2b$0$7623$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 02 Dec 2009 02:13:15 CET NNTP-Posting-Host: 5dd5c742.newsspool1.arcor-online.net X-Trace: DXC=BQmEa=\<9oim7>ihJR;B_cic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbTT2:ZAgWN2aPCY\c7>ejVhB08Yed0=a>aHQ=n5c=?^Cl X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8279 Date: 2009-12-02T02:13:15+01:00 List-Id: On 12/1/09 7:47 PM, Dmitry A. Kazakov wrote: > It cannot be declared of Car, if it is not. Which brings us (or me, at least) to the problem of whether or not the meaning of an Ada program (or a sequential subprogram) will change if object X really "is" after "begin" or whether its physical existence is allowed start just before actual use. :-) X might show its existence through side effects of its default initialization. Rather implicit if the effect is important. >> There is no way to perform an operation involving X in >> its own declaration. > > But it can be used right after the declaration. Sure, but it isn't used, and the compiler will make sure it isn't unless it has a value. > why not to > allow the programmer to say exactly this: do not allow default constructors > for this type? I would even make this a default. E.g. if the programmer > does not explicitly allow default constructors they are forbidden. So > > X : T; -- Is always illegal unless I do some actions Or maybe this could mean that if there is no explict specification of actions associated with the declaration, X must be considered uninitialized in the following text. Some syntax might be nice to have. > Ada does not specify what happens with out parameters updated before an > exception gets raised in the body of Foo: > > procedure Foo (X : out Car) is > begin > if HALT (p) then > raise Baz; -- Is this legal? > else > X := Merzedes; > end if; > end Foo; If we were to integrate exceptions into normal control flow like Java does? Here is what Java does when the constructor may raise an exception (taking the role of Foo above): if (some_condition) { try { spare = new Dummy.Tire(); } catch (Exception e) { ; } // this line not accepted by a Java compiler: its_color = spare.rim_color; // <----- } // this line not accepted by a Java compiler: its_color = spare.rim_color; // <----- > 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? From the Java point of view, there are no false positives or negatives. The rule is pretty clear, I think. Assuming that Ada programmers will be able to say "is initialized" for just a variable declaration, there should not be any false positives or negatives. There could be more reliance on the programmer, though, not sure. > My example illustrated a situation where an > uninitialized value might be an advantage, because one possible outcome of > Foo is exception propagation, in which case leaving Result raw could save > some vital nanoseconds of execution time. I don't buy this. Whether the out mode variable had been initialized in the body or not, the exceptional situation might have destroyed the value of the out mode parameter. A variable would not be considered initialized, I'd think, in an exception handler, unless the programmer says so (or assigns a value).