develooper Front page | perl.perl6.language | Postings from August 2010

Re: Smart match isn't on Bool

Thread Previous | Thread Next
From:
Mark J. Reed
Date:
August 2, 2010 11:02
Subject:
Re: Smart match isn't on Bool
Message ID:
AANLkTikzRkfRQbTSwax8a1gEyhY88S7r_rUrHT0uAXzs@mail.gmail.com
On Sun, Aug 1, 2010 at 6:02 PM, Jonathan Worthington <jonathan@jnthn.net> wrote:
> No, given-when is smart-matching. The RHS of a smart-match decides what
> happens. If you do True ~~ 1 then that's 1.ACCEPTS(True) which is going to
> do +True and thus match.

OK, but what about 0 ~~ True?  That's what started this thread,
extricated from the complicating trappings of given/when.  Right now,
(anything ~~ True) is true, and IMHO that's a misfeature; it's at
least surprising.  I'd expect (anything ~~ True) to be synonymous with
?(anything): true only if the LHS boolifies to true. By the same
token, (anything ~~ False) would be synonymous with !?(anything).

I don't think the capability to use an arbitrary
block/sub/method/boolean as a "when" condition should trump the
intuitiveness of smartmatching.   Instead of overloading the
smartmatch, I think we need a different way of specifying a condition
that isn't meant to be compared to the topic, and so doesn't invoke
smartmatching at all: it's just evaluated in Boolean context as-is.  I
like the suggestion of "whenever" for that; it has the "no matter
what" sense that goes with ignoring the topic.

-Mark












-- 
Mark J. Reed <markjreed@gmail.com>

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