At the moment I'm leaning toward:

    $pattern.accepts($thing)
    $pattern.rejects($thing)

and going the other way

    $thing ~~ $pattern
    $thing.match($pattern)
    $thing.subst($pattern)

and most generally, something like:

    $thing.does($pattern)
    $thing.when($pattern)

By the way, the Pattern type is already called Selector in the
synopses.  Or perhaps Selector is a bit more general.  Arguably Pattern
is the role that defines .accepts and .rejects,  but Selector is
really the Pattern|Junction type you use in a signature.  But we can't
just have Pattern does Junction or everything turns into a junction.  :/

Or maybe they should be the other way around, where Selector is the role
and Pattern is the sig type.  Or maybe the sig type should be Where so
we can say

    multi grep (Where $where, [EMAIL PROTECTED]) {...}

and call it with :where{...} or where => {...}.  Selector is kind of
a stupid name in any event.

Anyway, that gives us:

    given $pattern {
        when .accepts(42) {...}
    }

which given typical usage patterns of switch statements is probably
adequately huffmanized, unless we want to go for something shorter
than accepts/rejects, like

    acc/rej
    pix/nix
    ok/bogus

Of course, all of the .rejects() variants could simply be spelled
.accepts().not, but that seem unnecessarily cruel.

Larry

Reply via email to