note
Dominus
Says [Errto]:
<blockquote><i>
Wouldn't it be more useful for the module to just die and report its own error message directly to the user (with the added benefit that he/she then
has a line number with which to inquire into the module's source)?
</i></blockquote>
Yes, it would. The reply above from [Zaxo] seems to miss the point---
a module that does not return a true value throws an exception <i>anyway</i>,
so nothing would be lost by saying that modules that want to
signal initialization failures should call <tt>die</tt>.<p>
I think Larry agrees that the "true value" thing was a mistake.
(Compounding the mistake was Larry's decision to make failure,
rather than success, the
default.)<p>
Way back when, I proposed that this mistake should be removed
in Perl 6; the revised proposal is <a href="http://dev.perl.org/perl6/rfc/55.html">here</a>.
While I was researching the proposal, I looked at all the modules distributed
with the current version of Perl 5 to see if the "return false value to indicate failure"
feature was actually used. It turned out it was, but very infrequently.
99 of the 102 modules ended with an explicit <tt>1;</tt>.
Two modules used the feature; the other called <tt>die</tt> explicitly
to indicate failure.<p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-3737">
<p>
--<br><font size="-2">
<a href="mailto:mjd-www-perlmonks+@plover.com">Mark Dominus</a><br>
<a href="http://perl.plover.com">Perl Paraphernalia</a><br></font>
</div></div>
504480
504489