develooper Front page | perl.perl5.porters | Postings from July 2018

Allowing require to return false

Thread Next
David Farrell
July 25, 2018 13:56
Allowing require to return false
Message ID:
Hi P5P folks,

A feature of Perl I really don't like is requiring modules to return a true
value. Here's why:

   - It feels gross appending a "1;" to every module I write
   - All Perl can do is croak with a generic error message that isn't very
   useful: " did not return a true value".
   - If a module encounters an init error should die with a meaningful
   error message instead
   - I don't think any other language has copied this feature ....
   including Perl 6
   - I would guess the only time any of us see this message is when we've
   forgotten to append "1;" to a new module
   - Removing it would not affect the vast majority (all?) of modules

I'm a Perl source code newbie but I wrote about a couple of implementations

I can imagine a few ways to do it:

   1. Remove the feature altogether - this would be breaking change if any
   modules use this feature
   2. Make it a feature - this would be safer but I doubt anyone would use
   the feature
   3. Deprecate the error and remove it in a future version

Frustratingly, I don't know if any of these are worth pursuing - I wonder
if anyone would write modules that didn't return a true value as they
wouldn't work on past versions of Perl. If we assume Perl is going to be
used for another 25 years, then maybe it's worth it.

What does everyone else think?

Thanks in advance,


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About