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

Relieving the return true at the end of packages

From:
Jose Luis Martinez
Date:
February 8, 2015 19:18
Subject:
Relieving the return true at the end of packages
Message ID:
20150206134119.17224.qmail@lists-nntp.develooper.com
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 if 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 try to see this as a .

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.

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.

I think this is only 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
jlmartinez@capside.com



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