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: 17 Dec 1994 12:52:01 -0500
Date: 1994-12-17T12:52:01-05:00	[thread overview]
Message-ID: <3cv8g1$nr3@gnat.cs.nyu.edu> (raw)
In-Reply-To: leschkes.787596069@ferret

Scott is surprised that GNAT can give a clear error message for the case
of an invalid attempt to use a one-element positional aggregate.

Indeed this error message can't possibly be given in all situations (because
otherwise the language could allow it!)

Basically the cases that GNAT cannot correct are cases where you write
valid Ada 95 code that simply isn't quite what you meant:

    procedure x (a : integer);
    procedure x (a : array_of_integer);

now you write

    x ((1));

thinking that you are calling the second version with an aggregate, when
in fact you have written a valid call to the first version.

However, if there is an error, GNAT does the following:

  if I expect type vector of clunk
  and I actually have something of type clunk
  and the expression in question is parenthesized

  then output the appropriate error message complaining about misuse
  of 1-element positional aggregates.

of course no error message can always be "right". When a compiler detects
an error, it is in the business of producing the best guess as to what
was intended. The above check is just one of many heuristics in the GNAT
error detection intended to give more accurate messages.

By the way, whenever you get an error message you don't like from GNAT,
send a note to gnat-report. It is impossible to always give good error
messages, but often such suggestions are useful in tuning up the error
messages.




      reply	other threads:[~1994-12-17 17:52 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
1994-12-16 16:41   ` Scott Leschke
1994-12-17 17:52     ` Robert Dewar [this message]
replies disabled

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