Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of nicholas (3034)

Sunday October 26, 2008
04:20 PM

Each to what it is good at

[ #37746 ]

A couple of things amused me in the blog that Ovid linked to. Ninh writes

Come to think of it, I find it kind of insulting that PHP thinks you need ugly training wheels like this in the first place. Last time I checked, the world wasn’t filled with scrawny developers that would come crying to their mommies after getting their first facepalm of “AmbiguousInvocationError”.

Um, but isn't he tilting at windmills? I thought that the whole philosophy of PHP was "easy things as easy as possible". Which, if Larry's water bed theory of language design holds, means that something has to give elsewhere.

Meanwhile, as part showing that :: works just fine in C++ as namespace and package separator, Ninh gives example code and notes

Yes, you’ve read this correctly. Unlike PHP, C++ will simply say that you’re a silly person to write “less-than-intelligent” stuff like this in the first place and thinks it is the responsibility of YOU, the programmer, to solve this problem.

Except, here's how his C++ compiler tells you, the programmer, that you have conflicting Foo::bars:

$ c++ -o test test.cpp
/var/tmp//ccCahjBl.s:47:FATAL:Symbol __ZN3Foo3barEv already defined.

Here's what my compiler made of it:

g++ clash.cc -o clash
/var/folders/TZ/TZzOop8WEdSNgET6iqWhPE+++TI/-Tmp-//ccMPeaMa.s:49:FATAL:Symbol __ZN3Foo3barEv already defined.

Yes, such a clear, concise error message, isn't it? Includes the file name and the line number of the conflict, so I can go straight to it in my editor. A best practice that every other language should be following.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • C++ is perhaps not the best example of scrutable error messages from compilers. (The single design decision in C++ with which I can wholeheartedly agree is "You don't pay for what you don't use. I'm not sure C++ always lives up to that in terms of the conceptual tax, however.)

  • Of course, not all compilers are stupid enough to leave the error reporting until assembly time:

    tony@mars:~/play$ icpc test.cpp
    test.cpp(11): error: "Foo" has already been declared in the current scope
      namespace Foo {
                ^

    compilation aborted for test.cpp (code 2)

  • Is it less inscrutable if you build with -g? Which, of course, the sensible C/C++ programmer will be doing anyway during development.

    Wait, what am I saying? A sensible C hacker? Hah!