Re: Patterns

2007-01-07 Thread Larry Wall
On Sun, Jan 07, 2007 at 03:33:19AM -0800, Jonathan Lang wrote: : IIRC, you don't even need .accepts for this. You could just say : : given $pattern { :when $a ~~ $_ { ... } :when $b ~~ $_ { ... } :when $c ~~ $_ { ... } : } : : ...since an explicit smart-match is a boolean expressio

Re: Patterns

2007-01-07 Thread Jonathan Lang
Larry Wall wrote: Lots of interesting ideas. But I don't think the reverse-test situation will arise all that frequently. How 'bout we let the user just say: my macro statement_control: { "when .accepts: " } or some such... IIRC, you don't even need .accepts for this. You could just sa

Re: Patterns

2007-01-06 Thread Larry Wall
Lots of interesting ideas. But I don't think the reverse-test situation will arise all that frequently. How 'bout we let the user just say: my macro statement_control: { "when .accepts: " } or some such... Larry

Re: Patterns

2007-01-06 Thread Ashley Winters
On 1/5/07, Larry Wall <[EMAIL PROTECTED]> wrote: Anyway, that gives us: given $pattern { when .accepts(42) {...} } I think this type of usage should be encouraged with a bit more huffmanization. My first thought would be to add C to invert the arguments to ~~ versus C. given @

Re: Patterns

2007-01-06 Thread Jonathan Lang
Larry Wall wrote: 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/b

Re: Patterns

2007-01-05 Thread Larry Wall
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,

Re: Patterns

2007-01-05 Thread Larry Wall
On Fri, Jan 05, 2007 at 08:47:18PM +, Luke Palmer wrote: : I propose that we remove the following two lines from the smart match : table in S03: : :HashAny hash entry existence exists $_{$x} :Array Any array contains item* any($_) === $x : : These are the two

Re: Patterns and junctions

2003-04-04 Thread Paul
--- Luke Palmer <[EMAIL PROTECTED]> wrote: [extremely large *SNIP*] > Maybe the "|"/"||" distinction isn't needed, and we just need a > declarator on rules that says they are side-effect-free, and can thus > be optimized. [snip] > I like this solution better than making a new operator. In Perl >

Re: Patterns and junctions

2003-04-04 Thread Luke Palmer
> --- "Adam D. Lopresto" <[EMAIL PROTECTED]> wrote: > > I propose that since the empty pattern is no longer legal (and > > about time), we use "|" in patterns to indicate alternation without > > preference, and "||" to indicate "try the first, then the second, > > etc". > > Hmm > A neat idea,

Re: Patterns and junctions

2003-04-04 Thread Paul
--- "Adam D. Lopresto" <[EMAIL PROTECTED]> wrote: > I propose that since the empty pattern is no longer legal (and > about time), we use "|" in patterns to indicate alternation without > preference, and "||" to indicate "try the first, then the second, > etc". Hmm A neat idea, but can you el