Front page | perl.perl5.porters |
Postings from January 2022
Re: Pre-RFC: a `module` keyword
Thread Previous
|
Thread Next
From:
Dan Book
Date:
January 24, 2022 21:13
Subject:
Re: Pre-RFC: a `module` keyword
Message ID:
CABMkAVVysXXzDXS3WS9LZLQ-JkC4B-eMKw6vy9T9OkY=Myf-zQ@mail.gmail.com
On Mon, Jan 24, 2022 at 3:58 PM Ovid via perl5-porters <
perl5-porters@perl.org> wrote:
> On Monday, 24 January 2022, 21:39:08 CET, Tomasz Konojacki <me@xenu.pl>
> wrote:
>
> > > * Strict, warnings, utf8 source, signatures, and "no feature
> 'indirect'" by default
> >
> > We can't make the "module" keyword visible without a feature flag. "use
> > VERSION" will still be needed and that enables all the nice stuff
> > anyway.
>
> My intention for the full RFC was:
>
> use feature 'module';
>
> > Well, apart from "use utf8". It's been decided that it's a bad
> > default:
> https://www.nntp.perl.org/group/perl.perl5.porters/2021/08/msg261164.html
>
> The change is lexically scoped, so ...
>
> use 5.38.0;
>
> module My::Module :version(.1) {
> # use utf8 is only applied here in brand new code
> }
>
> # use utf8 does not apply here
>
The reasons for it being a "bad default" are not elided by only being used
for new code.
> > > * :export is handled natively leaving the import() free for other uses
> >
> > I don't see why a new keyword is needed for that. If we want ':export'
> > attribute (which is an interesting idea), it can be implemented without
> > the "module" keyword. Perl already supports attributes on subs and we
> > already have a few built-in ones (such as :const, :method etc.).
>
> There is no new keyword. Instead, this follows the Corinna "KIM syntax" (
> https://ovid.github.io/articles/language-design-consistency.html) to
> ensure language design consistency. :import is a modifier, not a keyword.
> This RFC would introduce only one new keyword, `module`, and `:import`
> doesn't exist without that feature.
>
I believe he was referring to adding the new keyword "module" for this,
when it could be done more generally.
> > The "package" keyword currently doesn't take attributes, but I think it
> > can be changed. "package Foo :bar" is a syntax error, so it probably
> > doesn't conflict with anything.
>
> Agreed, but I'm trying to create something which is entirely lexically
> scoped in a new syntax to avoid complicating existing code.
>
Restricting it to a block is not required for it to be lexically scoped for
new code - feature bundles already do this.
-Dan
Thread Previous
|
Thread Next