develooper Front page | perl.perl5.porters | Postings from September 2012

Re: given/when/~~ "final" thoughts (ha ha ha)

Thread Previous | Thread Next
From:
Jesse Luehrs
Date:
September 17, 2012 07:07
Subject:
Re: given/when/~~ "final" thoughts (ha ha ha)
Message ID:
20120917140719.GP11137@tozt.net
On Mon, Sep 17, 2012 at 09:59:49AM +0100, Smylers wrote:
> > I found Smylers’ argument (<20120905143040.GZ1742@stripey.com>)
> > convincing
> 
> Thanks -- glad it was of use.
> 
> > so I implemented it like this:
> > 
> >  $x ~~ undef
> >  $x ~~ $overloaded
> >  $x ~~ sub{}
> >  $x ~~ qr//
> >  $x ~~ $anthing_else # fall back to eq
> > 
> > But that makes ~~[] do the wrong thing silently in existing code, so
> > adding this before the last case would improve it:
> > 
> >  $x ~~ $other_ref # croak
> 
> Yes, good point.
> 
> How about restricting $other_ref to mean 'other references that aren't
> blessed objects with overloaded stringification'? That way things like
> Class::Path objects still just match as strings, without having to
> explicitly stringify them.

Yes, $overloaded should mean any of '~~', '&{}', 'qr', or '""'
overloading (checked in that order, except potentially croaking for
ambiguity if '&{}' and 'qr' are both provided, but '~~' isn't).

-doy

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