develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123768] Relieving the "return true" at the end of packages

Thread Next
From:
Jose Luis Martinez
Date:
February 10, 2015 21:40
Subject:
[perl #123768] Relieving the "return true" at the end of packages
Message ID:
rt-4.0.18-7429-1423472936-666.123768-75-0@perl.org
# New Ticket Created by  Jose Luis Martinez 
# Please include the string:  [perl #123768]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123768 >


Hello,

    I've been asking myself if it's not too wild to make the package keyword return true if it's used with a BLOCK and everything inside it is OK. Since I don't know enough about perl internals, I thought to seek out to the people who know best, so please see this as a feature request.

If package BLOCK returned true, packages that only declare a class would be relieved of having to put the "1;" at the end of the package, which I think is one of Perls' warts (newcomers always ask why the hell this has to be).

A file like:
---- FILE Class.pm -----
package MyClass {

}
------------------------
would simply work when used.


>From a backcompat point of view, if there is more code after the package, that would be evaluated normally, so all old code should work.

---- FILE Class.pm -----
package MyClass {

}
0;
------------------------
shouldn't let you use it.

It would only be appliable to "package BLOCK" and "package VERSION BLOCK", but if you write "Modern Perl", it would be helpful.

I'm sorry I don't know enough about perls' internals to make a patch, but I'd be happy to write tests if p5p thinks it's a sane feature to have.

Best Regards,

Jose Luis Martinez
JLMARTIN on CPAN


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About