develooper Front page | perl.perl5.porters | Postings from December 2017

Re: Revisiting smart match

Thread Previous | Thread Next
From:
Karen Etheridge
Date:
December 19, 2017 04:13
Subject:
Re: Revisiting smart match
Message ID:
CAPJsHfBBMXiyS+bvvTEiq2f=XGxpVnJc311p1QF3QutndWOA8A@mail.gmail.com
On Mon, Dec 18, 2017 at 7:38 PM, Dan Book <grinnz@gmail.com> wrote:

> The intent is that the two keywords will disambiguate `when`s currently
> ambiguous behavior; it can either apply a smartmatch between its operand
> and the topic, or it can test an expression for truthiness.
>
‚Äč
Why can't when_or_whatever_it_is(...) simply evaluate the expression
inside, no matter what that expression is? Indeed I thought that's how it
already worked (aside from the complicated ~~ behaviour).  The fact that
the ~~ operator is changing at the same time is orthogonal:

    given ($foo) {
        when ($truthy) { ... }
        when ($_ == 1) { ... }
        when ($x == 1) { ... }                          # doesn't actually
use $_; so what?
        when ($_ eq 'hello world') { ... }
        when ($_ ~~ $d) { ... }
    }

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