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

Re: Pre-RFC: a `module` keyword

Thread Previous | Thread Next
From:
Tom Molesworth via perl5-porters
Date:
January 24, 2022 23:53
Subject:
Re: Pre-RFC: a `module` keyword
Message ID:
CAGXhHdmU4t-ddfhfc3=a1r+=uPPWSBasLJK9TpG-o+Zwsq=aVA@mail.gmail.com
On Tue, 25 Jan 2022 at 06:47, Chad Granum <exodist7@gmail.com> 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/whatever.pl 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


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