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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4e180de737833224 X-Google-Attributes: gid103376,public From: bbalfour@std.caci.com (Brad Balfour) Subject: Re: Ada Java question => clarification Date: 1997/03/03 Message-ID: #1/1 X-Deja-AN: 222806457 References: <33167E7E.4351@fn3.freenet.tlh.fl.us> Organization: CACI, Inc. Newsgroups: comp.lang.ada Date: 1997-03-03T00:00:00+00:00 List-Id: In article , dewar@merv.cs.nyu.edu (Robert Dewar) wrote: >Brad said > >>Despite the two RM95 references quoted above, the real reason is found in >4.9(24) which let's us know that a static constant must be a full constant >>declaration or a renaming. java.awt.event.UP is a constant integer whose >>value is supplied via a pragma Import. This means that it is constant, but >>*not* a static constant. > >Two comments. First, it is always hard to guess why someone may not understand >something. Whether Brad's *real* reference is any more correct than the >RM references given depends on what you do and do not understand. If your >problem was that you did not realize that case statements required static >constants, then the original reference was fine. if you knew that, but >did not know what a static constant is, then some other RM reference is >right, if you know what a static constant is, but had forgotten that a >pragma Import does not make a constant static, then some other reference >is right, if you want to know WHY a pragma Import does not make a constant >static ("Hey, look at my Java code, it is obviously a static constant there"), >then some other RM reference is appropriate. That's the trouble with giving >an RM reference. You will never know which is the right one, and if you give >a wrong one, you waste the programmer's time on a wild goose chase. Well, here's the logic I used when claiming that the two references to 3.8.1(8) & 5.4(5) in the error message (repeated just below) weren't as much help as 4.9(24): WHEN java.awt.event.UP => return true; keydown.ada: Error: line 30 col 27 LRM:3.8.1(8) & 5.4(5), The expression in the discrete choice must be static The error message text tells me that the "discrete choice must be static". The discrete choice is java.awt.event.UP. [note: In the source code one can see that java.awt.event.UP is declared as a constant integer. The big question is what's wrong with using a java.awt.event.UP in this context] When I check out 3.8.1(8), it tells me just what the message said: that the choice must be static. No indication here why a constant integer isn't static. Let's move on... I check out 5.4(5) and am told the same thing again: "the expressions and discrete_ranges... shall be static." Again, no indication on why a constant integer isn't static. These two RM95 references support the compilers assertiion that the expression choice must be static. They are correct references, they just aren't useful.The programmer put an non static value in the choice, so pointing the person to an assertion that the value must be static doesn't tell you much; especially if the value put in the choice *seems static*, i.e., its a constant integer. By a basic understanding of the term static, a constant integer looks like a static thing. It's only when you look at 4.9(24) that you get a definition of what is or is not static and find out that the constant integer which is imported is *not* static. My comment isn't that the references are wrong or bad, just incomplete. Adding in a reference to the definition of static in 4.9(24) would help an error message that tells the programmer that the expression must be static. Robert also writes: >Brad wrote: >>So, unfortunately, you need to change the case statement into an if >>statement. > >Second, I don't see what is so unfortunate about this, it seems, if you think >about it, a natural restriction. I guess you could say it is unfortunate that >we do not have a kind of combined Ada-Java standard, with combined semantics, >and a combined compiler, but that would be asking a lot :-) I only meant that it is unfortunate since the person already wrote a case statement. Therefore, they have to spend 30 seconds in the editor to change it to an if statement. That's all. I had no further expectations. Just sympathy for the (quick) code change needed. Brad -- Brad Balfour SIGAda WWW Server CACI, Inc. http://www.acm.org/sigada/ (703) 277-6767 and also try: bbalfour@std.caci.com http://www.adahome.com/ 3930 Pender Drive Fairfax, VA 22030 "...they even have rules for exceptions" -- Dewar and Schonberg