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

Re: smartmatch needs your eyes

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
October 6, 2015 15:20
Subject:
Re: smartmatch needs your eyes
Message ID:
20151006152001.GA20288@cancer.codesimply.com
* 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,
with none of the utter madness now in evidence.  when(1) was hotly debated for
the sake of ==1, but in the end I said no, despite being briefly distracted by
its shine.

So, C<< when (1) { ... } >> should be an error.  It could be compile-time, but
runtime will do for now.

C<< when($x) >> cannot be compile time, because $x could contain a valid value
for the rhs of ~~.

> I'm very confused!

I hope this has disconfused you.

-- 
rjbs

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