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

Re: YA smartmatch proposal

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
October 12, 2015 10:17
Subject:
Re: YA smartmatch proposal
Message ID:
20151012101751.GL16789@iabyn.com
On Wed, Oct 07, 2015 at 07:07:53PM +0200, Lukas Mai wrote:
> Am 07.10.2015 um 10:24 schrieb Dave Mitchell:
> >
> >What I think we should do:
> >
> >1. Get rid of the ~~  operator altogether, plus '~~' overloading.
> >
> >2. Make when's behaviour entirely dependent on the *compile-time* class
> >of of its arg. In particular, make 'when (FOO)' have exactly the following
> >behaviours:
> >
> >     FOO             condition evaluates to
> >     --------------  ----------------------
> >     literal undef             !defined($_)
> >     numeric const                $_ == FOO
> >     literal pattern              $_ ~= FOO
> >     all else                     $_ eq FOO
> >
> >3. when { FOO } has condition FOO.
> 
> (You typo'd =~ as ~= above)

Oh yeah :-(

> This would mean 'when (qr/.../)' becomes 'when { $_ eq qr/.../ }'.

Good point. So a literal qr// will have to be accepted as well as a
literal //, perhaps along with a warning that "given(qr/.../) better
written as given(/.../)" ?

-- 
A walk of a thousand miles begins with a single step...
then continues for another 1,999,999 or so.

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