develooper Front page | perl.perl5.porters | Postings from January 2022

Re: Pre-RFC: a `module` keyword

Thread Previous | Thread Next
Tom Molesworth via perl5-porters
January 24, 2022 23:53
Re: Pre-RFC: a `module` keyword
Message ID:
On Tue, 25 Jan 2022 at 06:47, Chad Granum <> wrote:

> What about auto-including the 'feature' if the very first line (second if
> there is a shebang) started with the 'module' keyword? That would be very
> unlikely to break compatibility with existing code, and allows less
> boilerplate for module-only files. Might not need the block scope in such
> cases either.

Too fragile...

Compare this:

 module Example { print "$x" } # compilation error, since `use strict` is
in effect

and this:

 # See examples/ for practical uses of this module
 module Example { print "$x" } # since this is no longer the first line, we
have no `strict`, no `warnings`

Plus all the usual versioning problems - defaults that seem reasonable now
will be outdated by the time Perl 5.46 is released.

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