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

Re: smartmatch needs your eyes

Thread Previous | Thread Next
Ricardo Signes
October 6, 2015 15:20
Re: smartmatch needs your eyes
Message ID:
* Dave Mitchell <> [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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About