develooper Front page | perl.perl5.porters | Postings from September 2011

Re: Perl 5.16 and Beyond.

Thread Previous | Thread Next
September 13, 2011 04:48
Re: Perl 5.16 and Beyond.
Message ID:
On Mon, Sep 12, 2011 at 12:28:47PM -0400, Jesse Vincent wrote:
> 	- New versions of Perl 5 should not break your existing software
> 	- Backward compatibility must not stop Perl 5 from evolving
> 	- From 'use v5.16' forward, Perl should start treating 'use v5.x'
>         statements as "try to give me a Perl that looks like v5.x" rather
>         than "give me at least v5.x"
> 	- We're awesome at modules. Where possible, we should be
>         modularizing core features.

In general, yes, yes, yes. (I've seen Jesse's talk twice, and we've
talked about it as well, so it isn't all new to me).

I do, however, like to make a note about the new meaning of "v5.x". At
first, my reaction was "yes, that's very logical, it's got to be better
than what we have now".

Then I wrote a module that does this:

    use 5.006;
    sub match_all {
        my ($subject, $pattern) = @_;

        our @matches = ();

        my $pat = ref $pattern ? $pattern : qr /$pattern/;

        use re 'eval';

        $subject =~
             (?{ push @matches =>
                 [map {substr $subject, $- [$_], $+ [$_] - $- [$_]} 1 .. $#-] })

        wantarray ? @matches : [@matches];  # Must copy.

It takes a pattern with captures, and returns every possible match.

It has "use 5.006;" there. It really means, "give me 5.006 or newer". 

In Jesse's scheme, from 5.16 onwards, this is going to mean "5.14
semantics".  But if this is run on 5.20, it shouldn't restrict itself
to patterns with 5.14 semantics. If it's run on 5.20, it should also
work on regexp constructs that were introduced in 5.18.

So, the deeper issue here is if "use 5.x" is going to mean "run with
5.x" semantics, you may end up with different parts of a program that
use different semantics for the same code, and interpret the same data
differently - just because one module uses "5.x" and the other "5.y".
(For instance, do we really want a program to use two modules, where
one module uses Unicode X.0 semantics, and another module Unicode
Y.0 semantics, possibly giving different results on "lc $str" for the
same $str?)

Now, this doesn't mean I'm against changing the meaning of "use 5.x". In
general, I think it's a good idea, and it will help Perl moving forwards.
But I think there are some issues that need to be addressed. And for
which I, at this moment, don't have a solution for.



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