Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: why require a true value

by Dominus (Parson)
on Nov 01, 2005 at 05:48 UTC ( #504511=note: print w/replies, xml ) Need Help??


in reply to Re^2: why require a true value
in thread why require a true value

Says Errto:
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)?
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 anyway, so nothing would be lost by saying that modules that want to signal initialization failures should call die.

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.)

Way back when, I proposed that this mistake should be removed in Perl 6; the revised proposal is here. 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 1;. Two modules used the feature; the other called die explicitly to indicate failure.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://504511]
help
Chatterbox?
[choroba]: After submitting the form, I'm getting "Sorry, we're really busy right now, please wait for a bit. This page will automagically refresh soon"
[hippo]: Still nothing via https
marto pictures someone trying to fix a problem, while the page gets battered by F5s :P
[hippo]: Who maintains deps? Is it barbie?
[choroba]: and it works

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2018-02-20 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (271 votes). Check out past polls.

    Notices?