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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd63afa4dc364b7e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-25 14:35:25 PST Newsgroups: comp.lang.ada Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!62.112.0.25!newsfeed.online.be!zur.uu.net!ash.uu.net!world!bobduff From: Robert A Duff Subject: Re: Static typing (Was Re: Better support for garbage collection) Sender: bobduff@world.std.com (Robert A Duff) Message-ID: Date: Sun, 25 Mar 2001 22:31:52 GMT References: <98m938$2iod0$1@ID-25716.news.dfncis.de><98pgs1$32up7$1@ID-25716.news.dfncis.de><98umc6$39coj$1@ID-25716.news.dfncis.de> Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.3/Emacs 19.34 Xref: supernews.google.com comp.lang.ada:6042 Date: 2001-03-25T22:31:52+00:00 List-Id: "Ken Garlington" writes: > "Robert A Duff" wrote in message > news:wccofutg3ku.fsf@world.std.com... > : "Ken Garlington" writes: > : > : > More generally, of course, there are rational numbers that are not > exactly > : > representable as floating point numbers, so I don't see why a compiler > : > should accept x/y as a floating-point literal. > : > : You misunderstand my point. > > No, I just disagree with it. With all respect, I must insist that: No, you don't disagree, you misunderstand. ;-) ;-) You misunderstand what I mean by "literal" (which is exactly what the Ada RM means by "literal", too). > : Of course x/y is not a literal. > : My claim is that you shouldn't have to write ".0" on a floating point > : literal that happens to be an integer. That is, > : > : X: Float := 0; > : Y: Float := 1/2; > : > : should be legal. > > But if 1/2 is not a literal, then what is it? Certainly 1/2 is not a literal. Not in Ada, and not by me. >... CW would say that it is a > division operation involving two integers; why should the result be a > floating-point number? I would say, it's a division operation involving two *literals* (where literal implies no particular type). The interpretation of those literals should be resolved by the context. >... If we are to have implicit casts of integers to > floating point values, why not then permit the more general: > > Y : Float := ferble; > > where "ferble" is a function that returns an integer (or, for that matter, > any fixed-point) type? Why not? Because it makes no sense. Converting type Standard.Integer to Standard.Float probably makes no sense. But implicitly converting "1" to (say) Float *does* make sense. I was only talking about literals. Note that Ada always converts literals to some particular type. Note also that I'm not advocating all manner of implicit conversions. Certainly no implicit conversions that might lose information. > For that matter, why not Y : Float := "one half"; as you suggested > (unintentionally) in a separate post? You got me there! ;-) > In general, I'm not a fan of DWIM compilers (PL/M being a favorite example > of mine). Agreed (in general). - Bob