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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,502eafcf316bcb10 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-12-19 23:42:35 PST Path: nntp.gmd.de!news.rwth-aachen.de!newsserver.rrzn.uni-hannover.de!aix11.hrz.uni-oldenburg.de!uniol!zib-berlin.de!fauern!xlink.net!sol.ctr.columbia.edu!howland.reston.ans.net!swiss.ans.net!cmcl2!thecourier.cims.nyu.edu!thecourier.cims.nyu.edu!nobody From: dewar@cs.nyu.edu (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: Ada can't initialize (aggregate) array of length 1? Date: 19 Dec 1994 09:20:25 -0500 Organization: Courant Institute of Mathematical Sciences Message-ID: <3d44r9$i1f@gnat.cs.nyu.edu> References: <1994Dec12.081230.24978@roxi.rz.fht-mannheim.de> <3clobf$r0p@gnat.cs.nyu.edu> <1994Dec16.113708.28668@roxi.rz.fht-mannheim.de> NNTP-Posting-Host: gnat.cs.nyu.edu Date: 1994-12-19T09:20:25-05:00 List-Id: "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.