Mailing List Archive

smartmatch and v5.36.0
Porters,

I propose that we remove "switch" from the 5.35 and 5.36 feature bundle. I have a draft MR <https://github.com/Perl/perl5/pull/18864> that does most or possibly all of the work.

What prevents this from going forward, apart from some testing?

--
rjbs
Re: smartmatch and v5.36.0 [ In reply to ]
On Sat, 19 Jun 2021 21:27:46 -0400
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:

> Porters,
>
> I propose that we remove "switch" from the 5.35 and 5.36 feature
> bundle. I have a draft MR <https://github.com/Perl/perl5/pull/18864>
> that does most or possibly all of the work.
>
> What prevents this from going forward, apart from some testing?

I think we all want shot of that thing, and I expect I won't be the
first to throw a party when it goes. But I'm not sure we want to remove
it until we have a better replacement, do we?

I have been experimenting with Syntax::Keyword::Match:

my $n = ...;

match($n : ==) {
case(1) { say "It's one" }
case(2) { say "It's two" }
case(3) { say "It's three" }
default { say "It's something else" }
}

but I'm not sure it's ready to go into core yet - still more features
and dogfooding to be done yet.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: smartmatch and v5.36.0 [ In reply to ]
On Sun, Jun 20, 2021, at 7:47 AM, Paul "LeoNerd" Evans wrote:
> I think we all want shot of that thing, and I expect I won't be the
> first to throw a party when it goes. But I'm not sure we want to remove
> it until we have a better replacement, do we?

I do.

I am absolutely not telling people, "We'd like a better matching feature, but until we have one, I encourage you to make use of given/when." I say, "Write the code without using given/when and maybe someday upgrade it to the new thing."

This isn't about removing smartmatch from the language. It's about not turning it on when somebody says "use v5.36".

--
rjbs
Re: smartmatch and v5.36.0 [ In reply to ]
On Sun, 20 Jun 2021 08:34:15 -0400, "Ricardo Signes"
<perl.p5p@rjbs.manxome.org> wrote:

> On Sun, Jun 20, 2021, at 7:47 AM, Paul "LeoNerd" Evans wrote:
> > I think we all want shot of that thing, and I expect I won't be the
> > first to throw a party when it goes. But I'm not sure we want to
> > remove it until we have a better replacement, do we?
>
> I do.
>
> I am absolutely not telling people, "We'd like a better matching
> feature, but until we have one, I encourage you to make use of
> given/when." I say, "Write the code without using given/when and
> maybe someday upgrade it to the new thing."
>
> This isn't about removing smartmatch from the language. It's about
> not turning it on when somebody says "use v5.36".

I still don't see the scope clearly.

As it currently stands, I have a script that uses

foreach my $foo (@list_of_foo) {
given ($foo) {
when ("foo") {

with 52 when entries spanning 208 lines. The version of this scripts
that used if/else was IIRC about three times as long, unmaintainable
and unreadable.

All the when's are fixed string or regex (another much smaller script
uses numeric constants and undef too).

So no, I *do* want the edge cases of switch gone and all problems that
switch had removed, but until we have something better, I want switch
as it is for the simple cases that cause no problems.
--
H.Merijn Brand https://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.33 porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
Re: smartmatch and v5.36.0 [ In reply to ]
On Sun, 20 Jun 2021 08:34:15 -0400
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:

> This isn't about removing smartmatch from the language. It's about
> not turning it on when somebody says "use v5.36".

Ohright, just the feature bundle.

Yeah, that seems a useful first step to discouraging it.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: smartmatch and v5.36.0 [ In reply to ]
On Mon, 21 Jun 2021 17:42:34 +0100, "Paul \"LeoNerd\" Evans"
<leonerd@leonerd.org.uk> wrote:

> On Sun, 20 Jun 2021 08:34:15 -0400
> "Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
>
> > This isn't about removing smartmatch from the language. It's about
> > not turning it on when somebody says "use v5.36".
>
> Ohright, just the feature bundle.
>
> Yeah, that seems a useful first step to discouraging it.

Ahh, right, I have no objections to that!

--
H.Merijn Brand https://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.33 porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
Re: smartmatch and v5.36.0 [ In reply to ]
2021-6-20 10:29 Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:

> Porters,
>
> I propose that we remove "switch" from the 5.35 and 5.36 feature bundle.
> I have a draft MR <https://github.com/Perl/perl5/pull/18864> that does
> most or possibly all of the work.
>
> What prevents this from going forward, apart from some testing?
>
> --
> rjbs
>

I agree with "remove switch from the 5.35 and 5.36 feature bundle" .
Re: smartmatch and v5.36.0 [ In reply to ]
On Mon, Jun 21, 2021 at 12:50 PM H.Merijn Brand <perl5@tux.freedom.nl>
wrote:

> On Mon, 21 Jun 2021 17:42:34 +0100, "Paul \"LeoNerd\" Evans"
> <leonerd@leonerd.org.uk> wrote:
>
> > On Sun, 20 Jun 2021 08:34:15 -0400
> > "Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
> >
> > > This isn't about removing smartmatch from the language. It's about
> > > not turning it on when somebody says "use v5.36".
> >
> > Ohright, just the feature bundle.
> >
> > Yeah, that seems a useful first step to discouraging it.
>
> Ahh, right, I have no objections to that!
>

+1
Re: smartmatch and v5.36.0 [ In reply to ]
On Sat, Jun 19, 2021, at 9:27 PM, Ricardo Signes wrote:
> I propose that we remove "switch" from the 5.35 and 5.36 feature bundle. I have a draft MR <https://github.com/Perl/perl5/pull/18864> that does most or possibly all of the work.

I have merged this.

As a reminder: this does not disable the feature and should not alter the behavior of any program currently running on any released stable version of perl. It just means that "use v5.36.0" will not enable the experimental "switch" feature.

--
rjbs