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

Re: Pre-RFC: a `module` keyword

Thread Previous | Thread Next
From:
Oodler 577 via perl5-porters
Date:
January 24, 2022 23:08
Subject:
Re: Pre-RFC: a `module` keyword
Message ID:
Ye8xchuPz60SOF0L@odin.sdf-eu.org
The best gamblers stop when they're ahead. I recommend we follow
the tempered course laided out in RJBS' email from the PRC, then
see what all can be back filled in "non-corina" POOP. I mean, there
are probably some sensible things C<bless> and C<package> could
provide in a backcompat way that would also fit whatever niche that
has yet to be identified as inspiration from what's moving ahead.

It's not unlike the feedback loop that at one point had developed
between perl 6 and perl 5, thought that seems to have run its
course. So maybe see if something similar is begs itself later?

I mean, I think Util::H2O "tremendously cleans up" a lot of hairy
procedural, hashref-heavy code with ad hoc accessors on refs
in-flight; but I also am not prepared to pre-RFC it's inclusion in
core or a dual life module - I am tempted, though. :-)

Cheers,
Brett

* Ovid via perl5-porters <perl5-porters@perl.org> [2022-01-24 19:20:41 +0000]:

> I've been thinking about this a lot and I wanted to run an idea past P5P. Corinna tremendously cleans up Perl's OOP capabilities. It would be nice to have something like that for procedural code. I have no sponsor for this, but I was thinking about a `module` keyword. It would complement Corinna syntax and look something like this:
> 
>     module Some::Utilities :version(3.14) {
>         # all subs with an :export tag can be imported individually
> 
>         # use Some::Utilities ':strings';
>         sub make_slug :export(strings) ($name) {
>             ...
>         }
> 
>         # use Some::Utilities ':numbers';
>         sub constrain :export(numbers) ( $min, $num, $max = undef ) {
>             ...
>         }
> 
>         # use Some::Utilities ':numbers';
>         sub weighted_pick :export(numbers) ($weight_for) {
>             ...
>         }
>     
>         # cannot be exported
>         sub _binary_range ( $elem, $list ) {
>             ...
>         }
>     }
> 
> Benefits:
> 
> * Postfix block lexically scopes changes
> * Strict, warnings, utf8 source, signatures, and "no feature 'indirect'" by default
> * :export is handled natively leaving the import() free for other uses
> * Yields a `1` to avoid needing to add `1` at the end of every file.
> 
> Deliberately limited in scope to make it smaller and easier to implement. I believe that with `module` and `class`, we have a solid foundation for releasing Perl 7.
> 
> Best,
> Ovid
> -- 
> IT consulting, training, specializing in Perl, databases, and agile development
> http://www.allaroundtheworld.fr/. 
> 
> Buy my book! - http://bit.ly/beginning_perl
> 

-- 
--
oodler@cpan.org
oodler577@sdf-eu.org
SDF-EU Public Access UNIX System - http://sdfeu.org
irc.perl.org #openmp #pdl #native

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