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

Re: YA smartmatch proposal

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
October 13, 2015 16:16
Subject:
Re: YA smartmatch proposal
Message ID:
20151013161558.GV3904@iabyn.com
On Tue, Oct 13, 2015 at 11:13:25AM -0400, Eric Brine wrote:
> On Mon, Oct 12, 2015 at 6:17 AM, Dave Mitchell <davem@iabyn.com> wrote:
> 
> > On Wed, Oct 07, 2015 at 07:07:53PM +0200, Lukas Mai wrote:
> > > 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(/.../)" ?
> >
> 
> Why?

Because its inefficient. It has to clone a new regex each time. Its like
doing sub {...}->(...) rather than f(...).

> "split(qr{...}, ...)" doesn't warn, and I use that whenever I want a
> delimiter other than "/".

Why not use m{....} ?

> Even "$_ =~ qr{...}" doesn't warn.

Yes, it's too late to change that. But if I had a time machine, I would
have added such a warning when qr// was introduced. But since this is new
(kinda), we have the opportunity to add a new warning without backcompat
issues.

-- 
My Dad used to say 'always fight fire with fire', which is probably why
he got thrown out of the fire brigade.

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