comp.lang.ada
 help / color / mirror / Atom feed
From: bbalfour@std.caci.com (Brad Balfour)
Subject: Re: Ada Java question => clarification
Date: 1997/03/03
Date: 1997-03-03T00:00:00+00:00	[thread overview]
Message-ID: <bbalfour-0303971357250001@stmac0088.std.caci.com> (raw)
In-Reply-To: dewar.857310278@merv


In article <dewar.857310278@merv>, 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




  reply	other threads:[~1997-03-03  0:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-26  0:00 Ada Java question Kendal Van Dyke
1997-02-27  0:00 ` Tucker Taft
1997-02-28  0:00   ` Ada Java question => clarification Kendal Van Dyke
1997-02-28  0:00     ` Tucker Taft
1997-02-28  0:00       ` Brad Balfour
1997-02-28  0:00         ` Ada Java question => oops!! Kendal Van Dyke
1997-02-28  0:00         ` Ada Java question => clarification Kendal Van Dyke
1997-02-28  0:00           ` Norman H. Cohen
1997-03-01  0:00             ` David Taylor
1997-03-02  0:00               ` Robert Dewar
1997-03-06  0:00                 ` David Taylor
1997-03-08  0:00                   ` tagged type auto-"Use", was " Tom Moran
1997-03-10  0:00                     ` Dennis Reimer
1997-03-09  0:00                   ` Robert Dewar
1997-03-09  0:00                     ` Larry Kilgallen
1997-03-09  0:00                       ` Robert Dewar
1997-03-15  0:00                         ` Matthew Heaney
1997-03-01  0:00           ` Fergus Henderson
1997-03-02  0:00         ` Robert Dewar
1997-03-03  0:00           ` Brad Balfour [this message]
1997-03-05  0:00             ` Robert Dewar
1997-03-05  0:00               ` Brad Balfour
1997-02-28  0:00 ` Ada Java question Tom Halliley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox