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,12283be683f6446b X-Google-Attributes: gid103376,public From: sb463ba@d250-hrz.uni-duisburg.de (Georg Bauhaus) Subject: Re: Elaborate compile-time error messages (was: GNAT Stream Read ...) Date: 1999/01/11 Message-ID: <77cprt$d90$1@news-hrz.uni-duisburg.de>#1/1 X-Deja-AN: 431212452 References: <76tsgd$s0o1@svlss.lmms.lmco.com> <76uv4j$njr$1@nnrp1.dejanews.com> <1999Jan6.072356.1@eisner> <369366F1.67C06BF0@pwfl.com> Organization: Uni-GH Duisburg Newsgroups: comp.lang.ada Date: 1999-01-11T00:00:00+00:00 List-Id: Marin David Condic (condicma@bogon.pwfl.com) wrote: : Larry Kilgallen wrote: : > Is there some set of programmers who get : > really mad at having the compiler be smarter : > than they are about the nature of a problem. (Two questions below.) Given two source files, both plain wrong (a.k.a. nonsense), admittedly, and differing only in the spelling of one character, namely the P in these two lines: < N : Integer := Private; -- capital "P" (yes, wrong anyway) > N : Integer := private; -- small "p" (yes, wrong anyway) ---------------- package Emsg is -- not: emsg! (small "e") N : Integer := Private; -- capital "P" (yes, wrong anyway) end Emsg; ---------------- gnatf -v -ds emsg.ads GNATF 3.09 (970121) Copyright 1991-1996 Free Software Foundation, Inc. Checking: emsg.ads (source file time stamp: 1998-12-29 02:42:43) Source recreated from tree for Emsg (spec) ------------------------------------------ package emsg is n : integer := private; end emsg; 2. N : Integer := Private; -- "P" (yes, wrong anyway) | >>> reserved word "private" cannot be used as identifier 3 lines: 1 error Compilation exited abnormally with code 1 at Tue Dec 29 03:42:43 To me, this error message is quite satisfactory. Then ---------------- package Emsg is -- not: emsg! (small "e") N : Integer := private; -- small "p" (yes, wrong anyway) end Emsg; ---------------- gnatf -v -ds emsg.ads GNATF 3.09 (970121) Copyright 1991-1996 Free Software Foundation, Inc. Checking: emsg.ads (source file time stamp: 1998-12-29 02:30:36) Source recreated from tree for Emsg (spec) ------------------------------------------ package emsg is n : integer := ; end emsg; 2. N : Integer := private; -- "P" (yes, wrong anyway) | >>> missing operand 3 lines: 1 error Compilation exited abnormally with code 1 at Tue Dec 29 03:30:38 So, this time I understand that ":=" is missing an operand. (right?) I explained to myself that these two very different error messages might be the result of GNAT checking style. Is this true? QUESTION 1: Why does GNAT behave so very differently when things are spelled differently? (Try compiling with "emsg" replacing "Emsg" in the above examples.) I came across this when brooding over an error message that informed me of a missing operand and an "is" that should be ":=", which felt right ( N : Integer is private; -- operand missing between "Integer" and "is", -- then "is" should be ":=". Is "is" an operator? GNAT 1.83 just wants a ";" there.). But, not knowing how a compiler works internally and the formal aspects of languages in general, I was wondering where the operator was. "is"? So, here is my second question: QUESTION 2: Is there a chance that someday GNAT will tell me *which* operator is missing what? (Or have I overlooked something?) More generally: Is there a way to have GNAT shout *why* it was expecting something? (Let me note (1) that it's still a pleasure working with GNAT while thinking of C/Perl and what the compilers say when you forgot to place a ';' somewhere. And (2), I see that I had better know how compilation is done in order to understand error messages, much like if I'm driving a car through the desert and know something about motors and brakes. But then, some people just want to ride somewhere...) with best regards, Georg