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

Re: smartmatch needs your eyes

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
October 6, 2015 16:03
Subject:
Re: smartmatch needs your eyes
Message ID:
20151006160330.GL3904@iabyn.com
On Tue, Oct 06, 2015 at 11:20:01AM -0400, Ricardo Signes wrote:
> * Dave Mitchell <davem@iabyn.com> [2015-10-06T10:26:19]
> > So will when(1) always need to be written as when($_ == 1) now?
> > And if so, are when(1) and when($x) now equivalent to
> > 
> >     if (1) { ...; break }
> >     if ($x) { ...; break }
> 
> The goal state is that when(...){...} is directly equivalent to a smartmatch,

So for final clarity, is

    when (EXPR) {...}

intended to always be exactly equal to 

   if ($_ =~ EXPR) {...; break }

(with the rules for smartmatch stating that it will croak for various RHS
values, such as a simple numeric 1)?

If so, how does one write something functionally equivalent to when(1)
now?



-- 
Counsellor Troi states something other than the blindingly obvious.
    -- Things That Never Happen in "Star Trek" #16

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