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=0.6 required=5.0 tests=BAYES_00,FROM_WORDY autolearn=no 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-31 11:32:21 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!news.stealth.net!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.com!newsmst01!postmaster.news.prodigy.com!newssvr16.news.prodigy.com.POSTED!not-for-mail From: "Ken Garlington" Newsgroups: comp.lang.ada References: Subject: Re: Static typing (Was Re: Better support for garbage collection) Organization: ex-FlashNet, now Prodigy X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: NNTP-Posting-Host: 65.65.210.62 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr16.news.prodigy.com 986067032 6207069 65.65.210.62 (Sat, 31 Mar 2001 14:30:32 EST) NNTP-Posting-Date: Sat, 31 Mar 2001 14:30:32 EST Date: Sat, 31 Mar 2001 19:30:32 GMT Xref: supernews.google.com comp.lang.ada:6293 Date: 2001-03-31T19:30:32+00:00 List-Id: "Robert A Duff" wrote in message news:wccvgorkl54.fsf@world.std.com... : > 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. Again, the inconsistency is rooted in an inability to articulate WHY it's "obvious" in one case, but not in another. Presumably, we want to write the language so that the expected result is "obvious" to the largest number of people. For example, if I see X: constant Float := 1/2; I would intuitively expect this to have the same effect as if I wrote A : constant Integer := 1; B : constant Integer := 2; X : constant Float := A/B; If they both work, then I would also expect the following to work: function Q (Z: in Float) return Float; X : constant Float := Q(A); and at this point we are talking about implicit casts, which I don't like. Not being able to articulate the difference here is the same problem as insisting that the term "floating-point" MUST be limited to hardware representations... it's fine, so long as everyone shares your mindset (and there's counter-evidence to that already). However, if someone believes otherwise, then they may be confused and frustrated when the more widespread definition is not supported by the language. : > 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. However, if all four "resolve just fine," then that has to mean that both 1 and 1.0 are both reals and integers. Again, why have liberal rules for numerics, but not for other literals? In your other post, you said: : My proposal does not "loosen" -- in fact (other than the minor ".0" : thing), my proposal makes more programs illegal -- it tightens. First, this seems to be a Bad Thing -- to make legal programs, that use a more strict definition of literals, illegal. Second, isn't this contradicted by the example above? GNAT says two of these are illegal, you say all four are legal. Note that it's not limited to ".0"; all sorts of literal forms (exponents, based numbers, etc.) would now be exchangable. All you have to do is leave off one digit (e.g. 1.00000E5 instead of 1.000001E5), and suddenly your floating-point value can be an integer! : > 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. What's the difference between that and having packages that define units of measure (feet_per_second, etc.), which has been done more than once? You wouldn't have to define every number, any more than "Furlongs_per_fortnight" is required. The point is that the language supports it, and a compiler vendor could include it if desired. :> J: constant String := a; -- is this a literal "a", or a reference to :> something that I forgot to import? Both are possible... : The a is an identifier, not a literal, and I don't propose to change : that. Again, WHY is it a an identifier, if there's no identifier named A in my program? Note that you can't use the same argument for J : constant String := 1; since this is obviously not an identifier; therefore it must be a string (just like 1/2 is obviously a floating point divide, not an integer divide, if I assign it to a floating-point number).