comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Ada can't initialize (aggregate) array of length 1?
Date: 19 Dec 1994 09:20:25 -0500
Date: 1994-12-19T09:20:25-05:00	[thread overview]
Message-ID: <3d44r9$i1f@gnat.cs.nyu.edu> (raw)
In-Reply-To: 1994Dec16.113708.28668@roxi.rz.fht-mannheim.de

"IN that case the error message was confusing"

As I said earlier giving the "right" message when an attempt is made to
use a one element aggregate is not generally always possible (because
otherwise the language could allow it).

In the case of an inner aggregate, which was the case at hand, it is
theoretically possible to still give the "right" message, but much
harder, because the expected type is not at hand (remember that
aggregates are resolved independent of context in a situation like
this). 

The GNAT processing is:

   if type array-of-x is expected, and we have a parenthesized x instead
   then give special error message.

What would be needed in the other case is much more complex:

   attempt to resolve array aggregate

   if it fails, see if there are cases of parenthesized expression(s) in
   the aggregate, and treat them as positional aggregates, and retru the
   resolution. if it works, then give the special error message

much more complex! furthermore if there are several parenthesized expressions
in the aggregate, say K of them, a really thorough attempt would require
2**K attempts at resolution, which is getting a bit out of hand..

The error message game is an interesting one of trading off effort vs
return. Correctness is not involved, since you can't always be correct
in the real sense (that would require telepathy), and it is trivial to
be formally correct (any error message at all, even a bomb saying simply
error, would be officially correct).

So you do the best you can!

As I requested before, always send in examples of confusing error messages,
it is pretty much impossible to tell how easy it is to "fix" such cases.

One more point is that the amount of effort that it is worth putting in
very much depends on ones estimate of the frequency of the error, and how
bad the consequences are of messing up.

For example, GNAT goes to rather strenous and complex efforts to diagnose
the misuse of IS for semicolon and vice versa in procedure specs and bodies.
But this is a case where the error is common, and the failure to do correct
error recovery can lead to VERY mysterious error messages.




  reply	other threads:[~1994-12-19 14:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-12-12  7:12 Ada can't initialize (aggregate) array of length 1? Dirk Zoller
1994-12-12 12:54 ` Gentle
1994-12-12 18:35   ` Bob Duff
1994-12-13 17:01   ` Jahn Rentmeister
1994-12-14  3:23   ` Robert Dewar
1994-12-12 13:20 ` R. William Beckwith
1994-12-16 13:34   ` gamache
1994-12-14  3:21 ` Robert Dewar
1994-12-16 10:37   ` Dirk Zoller
1994-12-19 14:20     ` Robert Dewar [this message]
1994-12-16 16:41   ` Scott Leschke
1994-12-17 17:52     ` Robert Dewar
replies disabled

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