On Mon, Sep 21, 2015 at 09:36:45AM -0400, Ricardo Signes wrote: > > This whole subthread is rebuilding my resolve. Plain scalars should go pound > sand. I don't believe I'll see a way to use them on the rhs of ~~ that will be > straightforward. > > I think we're better off with helpers to build tests, like Smart::Match. > > sub smartgrep ($test, @items) { return grep { $_ ~~ $test } @items; } > > If we want the test to be numeric, we can call: > > smartgrep num(4), @input; > > Making that faster than 0+@input subroutine calls should be possible in the > future if someone decides it's worth doing. > > Meanwhile, we have: > > when { $_ == 1 } { ... } > > ...which is still shorter than: > > if ($_ == 1) { ...; break; } > > Also, if we disallow "when (5)" now, it can be enabled later, but if we allow > it now, we're stuck with it. > > That was the plan when I first posted to this thread, and I don't know why I > got distracted by this idea that I'd already dismissed ages ago. Coming late to this thread... I'm still not clear what the proposal is for when() semantics. Is when() going to be completely dumb in future, rather than the zillions of special cases as now, where it sometimes invokes smart match, and sometimes doesn't? So will when(1) always need to be written as when($_ == 1) now? And if so, are when(1) and when($x) now equivalent to if (1) { ...; break } if ($x) { ...; break } Or are they compile-time errors? I'm very confused! -- "Foul and greedy Dwarf - you have eaten the last candle." -- "Hordes of the Things", BBC Radio.Thread Previous | Thread Next