W
Wolfram Humann
When perl runs using the debugger or if you "use diagnostics", (some?)
compile time errors will be hidden by an error from Carp::Heavy.
Example:
Execution of -e aborted due to compilation errors.
perl/perl5.10.1/lib/5.10.1/Carp/Heavy.pm line 11.
Compilation failed in require at /home/wolframh/perl/perl5.10.1/lib/
5.10.1/Carp.pm line 33.
Global symbol "$num" requires explicit package name at -e line
1.
Execution of -e aborted due to compilation errors.
at -e line 1
In the first example, the problem with $num is reported correctly.
The second example reports an error in Carp::Heavy -- even though the
problem is still $num. This can be verified by adding 'my' before
$num: the error message goes away. The same misguiding error message
happens with
websearch for '"failed in require" "carp heavy"' to see some. The
replies often tell pepole how to correct their code and make the error
message go away but it would be better if they got a decent error
message in the first place so they can fix their bugs without external
help
The most helpful reply I found was from Ilya Zakharevich at
http://groups.google.com/group/comp.lang.perl.misc/msg/efa2d9659eb48e90.
This told me that the error message from Carp::Heavy goes away and the
*real* error message reappears, when Carp is fully loaded (i.e.
ncluding Carp::Heavy) before the error occurs. The third example shows
that this is indeed the case.
While in "normal" code it makes sense to defer loading Carp::Heavy
until it's really required (e.g. in production code, the probabilty of
an error occurring that needs to reported should be low), this is not
the case with the debugger or "use diagnostics":
a) the probability is high that Carp::Heavy will be loaded anyway is
high
b) in such a "bug hunting" scenario, the annoyance of a misleading
error message by far outweighs a few extra milliseconds of startup
time.
I would therefore propose, that the debugger and "use diagostics" do a
"use Carp::Heavy" internally. What do you think?
Wolfram
compile time errors will be hidden by an error from Carp::Heavy.
Example:
Global symbol "$num" requires explicit package name at -e line 1.perl -E'use strict; $num = 17'
Execution of -e aborted due to compilation errors.
BEGIN not safe after errors--compilation aborted at /home/wolframh/perl -E'use diagnostics "-t"; use strict; $num = 17'
perl/perl5.10.1/lib/5.10.1/Carp/Heavy.pm line 11.
Compilation failed in require at /home/wolframh/perl/perl5.10.1/lib/
5.10.1/Carp.pm line 33.
Uncaught exception from user code:perl -E'use Carp::Heavy; use diagnostics "-t"; use strict; $num = 17'
Global symbol "$num" requires explicit package name at -e line
1.
Execution of -e aborted due to compilation errors.
at -e line 1
In the first example, the problem with $num is reported correctly.
The second example reports an error in Carp::Heavy -- even though the
problem is still $num. This can be verified by adding 'my' before
$num: the error message goes away. The same misguiding error message
happens with
This effect has been reported by many people at various places. Use aperl -d -E'use strict; $num = 12'
websearch for '"failed in require" "carp heavy"' to see some. The
replies often tell pepole how to correct their code and make the error
message go away but it would be better if they got a decent error
message in the first place so they can fix their bugs without external
help
The most helpful reply I found was from Ilya Zakharevich at
http://groups.google.com/group/comp.lang.perl.misc/msg/efa2d9659eb48e90.
This told me that the error message from Carp::Heavy goes away and the
*real* error message reappears, when Carp is fully loaded (i.e.
ncluding Carp::Heavy) before the error occurs. The third example shows
that this is indeed the case.
While in "normal" code it makes sense to defer loading Carp::Heavy
until it's really required (e.g. in production code, the probabilty of
an error occurring that needs to reported should be low), this is not
the case with the debugger or "use diagnostics":
a) the probability is high that Carp::Heavy will be loaded anyway is
high
b) in such a "bug hunting" scenario, the annoyance of a misleading
error message by far outweighs a few extra milliseconds of startup
time.
I would therefore propose, that the debugger and "use diagostics" do a
"use Carp::Heavy" internally. What do you think?
Wolfram