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-30 13:24:05 PST Newsgroups: comp.lang.ada Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!chcgil2-snf1.gtei.net!news.gtei.net!newspump.sol.net!nntp.msen.com!uunet!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: Fri, 30 Mar 2001 21:21:59 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><4mzw6.414$OQ6.73321643@newssvr16.news.prodigy.com> Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.3/Emacs 19.34 Xref: supernews.google.com comp.lang.ada:6275 Date: 2001-03-30T21:21:59+00:00 List-Id: "Ken Garlington" writes: > : > X : constant String := 1_000; > : > > : > Is the underscore retained? > : > : Probably the right rule is that string literals must have quotes, so the > : above is illegal. > > Back to form of the literal contributing to its interpretation (*sigh*) > > : Do you understand the rather subtle distinction > : between letting the literal's form determine its type, versus making > : certain forms illegal after having determined the type (clearly String, > : in the above case)? > > If it's clearly String, why would 1_000 be an illegal string? If you can > explain that, then I might understand the distinction... This is key. The reason why you don't understand my ideas (and think I'm being self-contradictory) is that you don't understand this distinction. I'll try to clarify: In the above example (in my proposal), the literal 1_000 is *interpreted* as being of type String (because that's what the context (quite obviously) requires). This does *not* imply that it's legal -- there are additional rules that require literals of a type to be of a certain form. Those rules should be chosen to avoid confusion. We both agreed that it's confusing to leave off the quotes in this case, so I'm imagining a rule making the above illegal. In other words, there are two steps: 1. Determine that 1_000 must be of type String (without noticing what the literal looks like). 2. Check that 1_000 is a valid form for a literal of type String. Of course the rules for what is valid form for a String are going to be different then for Integer or Float. I suppose there's actually: 3. Given a valid literal, determine its value. This is also type dependent. > I understand that you see it as a "malformed literal"... but WHY is it a > malformed literal, any more than > > X : constant Float := 1; > > would NOT be a malformed literal under your proposal? Isn't the desired > result "obvious" in each case? I find it obvious in this case, but not in the String case. Shrug. That's only a minor point. > OK, but then note that the following will (almost) always be illegal: > > X : constant Float := 1/2; > X: constant Integer := 1/2; > X: constant Float := 1.0/2.0; > X: constant Integer := 1.0/2.0; > > because it's ambiguous which "/" operator is intended here (assuming one is > visible for both types). Currently, only two are illegal. Do we really want > to break existing programs in this manner? No. Again, you misunderstand how overload resolution works. There is only one "/" that returns Float, and that's the one chosen in the first example. Therefore, the two literals would also be interpreted as Float. Likewise, in the other three examples -- they would resolve just fine. > X: = constant Float := To_Float("one half"); > > All you'd have to do is agree on common descriptions and have at it! I presume you're being sarcastic. Writing down the rules for English language descriptions of numbers (in words) would be a big job, and a big waste of time. - Bob