On Mon, Aug 2, 2010 at 2:02 PM, Mark J. Reed <markjr...@gmail.com> wrote: > On Sun, Aug 1, 2010 at 6:02 PM, Jonathan Worthington <jonat...@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).
Again, sorry for starting a long thread (I seem to do that, and I swear I'm not trying... just pointing out the surprises I run into as I try to code). I want to stress that what you've said above is kind of moot: the spec says that ~~True gets a parser warning, so we can consider that deprecated. The only usage we're supporting, here, is a Bool value stored in a variable or otherwise generated. I would argue that that's even worse. For example: my Bool $trash-status = take-out-the-trash(); ... some time later ... my Bool $dishes-status = wash-the-dishes(); if !$dishes-status && $dishes-status ~~ $trash-status { say "No chores this week!"; } Of course, that's a bug, but imagine the poor maintenance programmer that tries to figure out what's going on. I feel for him/her. The only advantage he/she will have is that this is likely to be so common an error that they'll quickly learn to look for it first when smart-matching is involved :-/ -- Aaron Sherman Email or GTalk: a...@ajs.com http://www.ajs.com/~ajs