On Fri, 01 Apr 2022 09:54:37 -0400 "Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote: > Item 5 is good. We should try to eliminate the need for "magic true > value" in v5.38, generally. Indeed; I think last time when we discussed the previous iteration of the idea ("module"), we said that overall everything can be already solved by the `use VERSION` and `package NAME VERSION {BLOCK}` features that already exist in Perl and have done for a very long time, apart from two small additions of: * A mechanism (maybe attribute?) to request per-function lexical exporting. * A named feature that causes the .pm file as a whole to yield a true value at the end. I forget what we called them but those could be spelled: use feature qw(export_attr yield_true); package Some::Module v1.23 { sub this_is_exported :export { ... } sub this_method_is_not { ... } my sub this_is_lexically_private { ... } } # no need for "1;" here because of the yield_true feature That can all work *right now* with the `package` keyword. Furthermore, the two new features, once implemented, could become part of a `use VERSION` bundle at some future version of perl, so you could simply write use v5.100; # has already enabled strict, warnings, signatures and # yield_true; has disabled indirect, etc... package Some::Module v1.23 { sub f :export ($x, $y) { ... } } Looking further over the (closed) PR from last time: https://github.com/Perl/RFCs/pull/11 What I said was: @Ovid I think the :export attribute could stand alone well in its own RFC. Do you want to write one up, or should I? A couple of further thoughts on it: * Perl core already reserves all the lowercase attribute names for its own future expansion. There's no need to use feature-guard it. We can add `:export` right now. * I think the named tags should take a leading colon; e.g. `:export(:strings)`. That way they visually match what the `use Module ':strings';` import line looks like, and also it gives us some space to put other options in there one day. I would definitely be in favour of seeing (two?) RFCs to specifically add these ideas: 1. An :export attribute for lexical exports (see quoted PR comment above) 2. A `use feature 'yield_true'` to avoid having to put "1;" at the end of the file; with a future plan to include that by default in the versioned feature bundles. I believe that combination, plus a proper understanding of how `use VERSION` and `package NAME VERSION {BLOCK}` already work in Perl, will fully cover the use-cases and benefits of your proposed "library" keyword, without the need for new keywords or a significant departure of existing Perl syntax. -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next