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

Re: smartmatch needs your eyes

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
September 21, 2015 14:10
Subject:
Re: smartmatch needs your eyes
Message ID:
CAHhgV8jqitGiMbSWV=rr_KVWBxYKAiDiCox50P8wiDFsZS1pjQ@mail.gmail.com
On Mon, Sep 21, 2015 at 3:36 PM, Ricardo Signes <perl.p5p@rjbs.manxome.org>
wrote:

>
> This whole subthread is rebuilding my resolve.  Plain scalars should go
> pound
> sand.  I don't believe I'll see a way to use them on the rhs of ~~ that
> will be
> straightforward.
>
> I think we're better off with helpers to build tests, like Smart::Match.
>
>   sub smartgrep ($test, @items) { return grep { $_ ~~ $test } @items; }
>
> If we want the test to be numeric, we can call:
>
>   smartgrep num(4), @input;
>
> Making that faster than 0+@input subroutine calls should be possible in
> the
> future if someone decides it's worth doing.
>
> Meanwhile, we have:
>
>   when { $_ == 1 } { ... }
>
> ...which is still shorter than:
>
>   if ($_ == 1) { ...; break; }
>
> Also, if we disallow "when (5)" now, it can be enabled later, but if we
> allow
> it now, we're stuck with it.
>
> That was the plan when I first posted to this thread, and I don't know why
> I
> got distracted by this idea that I'd already dismissed ages ago.
>

The question then is, how do we deal with backwards compatibility?

Leon

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