(Many of you may find this off topic, but I consider it being of C++
educational value.)
What would you think of having your compiler not just give you an error
message, but also tell you what paragraph in the standard you broke?
Regards,
Daniel
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I'm not sure what advantage this would have. I think very few people
have copies of the standard. I think it would just be more confusing to
a lot of people. And what do you do if it violates multiple paragraphs
(as a lot of syntax errors do)?
I also think it would be a large cost for the compiler developers to
implement such a feature.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Interesting idea. Diagnostics of compilers are usually documented
somewhere so you may take the list and try to match it with standard.
There are likely problems however. Compiler vendors are already
putting lot of effort into making the diagnostics as helpful they can.
It is difficult since compiler is just a program and it has limits.
For example compiler tells that it did not expect ';' at that spot or
that it found a name that is unspecified for it. It rarely can tell
what exactly you did likely want to do so it does not know what you
did violate.
Such a teaching compiler however should instead understand what you
did try to do. It is often hard even for other human being without
asking from the author of non-compiling code.
It would be very nice if the standard was intelligible. As is, it
would be of some minor use, but as I've said in other threads: C++
programmers program more to accept practice and known implementations
than they do to the often vague, unclear, poorly organized official
standard.
As is, I much prefer error messages which say "Did not expect <x>.
<blah blah blah>. Did you mean for the dependent name to be a type?
Try using "typename"." which some modern compilers will do.
> What would you think of having your compiler not just give you an error
> message, but also tell you what paragraph in the standard you broke?
This would be a good idea. And I would like to have a C++ compiler, which
would detect all undefined behavior locations in my code, too :-)
--
Frank Buss, f...@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Infeasible. Firstly, each version of the standard differs, sometimes
drastically. Secondly, many errors don't correspond to any single
location in the standard, and sometimes even correspond to no location
at all (i.e. using a syntactic form that does not exist).
>It would be very nice if the standard was intelligible. As is, it
>would be of some minor use, but as I've said in other threads: C++
>programmers program more to accept practice and known implementations
>than they do to the often vague, unclear, poorly organized official
>standard.
Look on the bright side - it's better than many. A standard should
favour precision over readability, but I agree that it isn't as good
on the former as it should be.
>As is, I much prefer error messages which say "Did not expect <x>.
><blah blah blah>. Did you mean for the dependent name to be a type?
>Try using "typename"." which some modern compilers will do.
Yeah. Fine when you make an obvious, common error. When you make
a more subtle one, you have to reverse engineer the message to find
out what it is objecting to.
Regards,
Nick Maclaren.
> Hi,
>
> (Many of you may find this off topic, but I consider it being of C++
> educational value.)
>
> What would you think of having your compiler not just give you an error
> message, but also tell you what paragraph in the standard you broke?
>
Many compilers already do that. They give error codes.
That's probably something best left to the tools that are used with the
compiler, such as an IDE. Some diagnostics are verbose enough now
without adding to them.
--
Ian Collins
When I was more naive (not that I'm not still naive), I used to wonder
"If it knows I'm missing a semicolon, why doesn't it just add it for
me?" :-)
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
> When I was more naive (not that I'm not still naive), I used to wonder
> "If it knows I'm missing a semicolon, why doesn't it just add it for
> me?" :-)
>
Back in the mid eighties, I used a DEC VAX C ompiler that tried to fix
up errors at compile time, it would insert a closing brace somewhere,
if it found one missing. It never seemed to insert it in the right
place, though. I started looking at warning messages really
carefully.
-- Daniel
--
They still exist. Many "syntax-aware editors" have such a feature.
Semicolons are not too bad, as the fixup is usually either correct,
or leads to another error, but correcting bracketting (especially
curly ones in languages like C and C++) is a nightmare.
Regards,
Nick Maclaren.
> Back in the mid eighties, I used a DEC VAX C ompiler that tried to fix
> up errors at compile time, it would insert a closing brace somewhere,
> if it found one missing. It never seemed to insert it in the right
> place, though. I started looking at warning messages really
> carefully.
That makes me think of COBOL, which I studied, and wrote student programs for, but never actually used. One of the many things I hated about COBOL was the multiple spellings of allowed keywords for a single concept. A real example: ZERO, ZEROES, ZEROS,
choose the one that suits your mood today!
http://www.felgall.com/cob3.htm
WRT the C++ proposal in this thread, I think it is a Real Bad Idea.