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

Re: Patterns

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

Re: Patterns

2007-01-05 Thread Larry Wall
two lines with Any on the right side. I want to remove : these so that we can have an extensible ~~ operator. : : You can think of $x ~~ $y as saying "$x matches $y", i.e. $y is some : data pattern and we are asking if $x conforms to it. I want to be : able to add my own kinds of pat

Patterns

2007-01-05 Thread Luke Palmer
have an extensible ~~ operator. You can think of $x ~~ $y as saying "$x matches $y", i.e. $y is some data pattern and we are asking if $x conforms to it. I want to be able to add my own kinds of patterns, and entries with Any in the right side undermine this. Why? Let's say I cr

Re: dis-junctive patterns

2005-11-22 Thread Larry Wall
On Tue, Nov 22, 2005 at 09:31:27AM +0200, Gaal Yahas wrote: : In pugs, r7961: : : my @pats = /1/, /2/; : say "MATCH" if 1 ~~ any @pats; # MATCH : say "MATCH" if 0 ~~ any @pats; # no match : : So far so good. But: : : my $junc = any @pats; : say "MATCH" if 1 ~~ $junc; # n

Re: dis-junctive patterns

2005-11-22 Thread TSa
HaloO, Gaal Yahas wrote: In pugs, r7961: my @pats = /1/, /2/; say "MATCH" if 1 ~~ any @pats; # MATCH say "MATCH" if 0 ~~ any @pats; # no match So far so good. But: my $junc = any @pats; say "MATCH" if 1 ~~ $junc; # no match say "MATCH" if 0 ~~ $junc; # no match

dis-junctive patterns

2005-11-21 Thread Gaal Yahas
In pugs, r7961: my @pats = /1/, /2/; say "MATCH" if 1 ~~ any @pats; # MATCH say "MATCH" if 0 ~~ any @pats; # no match So far so good. But: my $junc = any @pats; say "MATCH" if 1 ~~ $junc; # no match say "MATCH" if 0 ~~ $junc; # no match Bug? Feature? -- Gaal Yaha

Re: Junctions, patterns, and fmap again

2005-09-20 Thread Stuart Cook
On 20/09/05, Luke Palmer <[EMAIL PROTECTED]> wrote: > The basic idea is that, alongside Functor, you have a Zippable theory > which defines: > > theory Zippable[::T] { > multi zip (T[::A], T[::B] --> T[:(::A, ::B)]) {...} > } > > Where that last coloney madness is a yet-to-be-prop

Re: Junctions, patterns, and fmap again

2005-09-19 Thread Luke Palmer
On 9/19/05, Luke Palmer <[EMAIL PROTECTED]> wrote > Well, I've written up the details in a 40 line Haskell program to make > sure it worked. I think I deleted the program, though. Nope. Here it is. And it was 22 lines. :-) http://svn.luqui.org/svn/misc/luke/work/code/haskell/hyper.hs Luke

Re: Junctions, patterns, and fmap again

2005-09-19 Thread Luke Palmer
On 9/19/05, Stuart Cook <[EMAIL PROTECTED]> wrote: > On 19/09/05, Luke Palmer <[EMAIL PROTECTED]> wrote: > > Part 1: fmap > > > > I have a plan for the $x »+« $y form (and also foo(»$x«, »$y«, »$z«)), > > but I don't want to go into that right now. It basically involves > > zipping the structures

Re: Junctions, patterns, and fmap again

2005-09-19 Thread Stuart Cook
t; > And the only thing that makes junctions different from Sets (which are > also Functors) is their behavior in boolean context (and their ability > to be Patterns; see below). I think this is really nice: we get rid of invisible junction magic, yet accessing that magic explicitly is on

Junctions, patterns, and fmap again

2005-09-18 Thread Luke Palmer
function for each of its values and reconstruct based on the return values. All in all, a Junction sounds like a perfect candidate to be a Functor. Except all the fmapping is implicit, which is what makes Junctions break the transitivity of <, the orthogonality of the patterns "1"

Re: Logic Programming with Rules (and Argument Patterns)

2005-03-09 Thread Ovid
--- Rod Adams <[EMAIL PROTECTED]> wrote: > I was just relaying the observation that the P6RE was fairly close to > being able to implement Logical Programming, which several people > seem to be trying to get into Perl in some fashion or another. When I get a chance to talk to someone about logic p

Re: Logic Programming with Rules (and Argument Patterns)

2005-03-09 Thread Rod Adams
Larry Wall wrote: I suspect it's another one of the many things we just try to stay within hailing distance of without trying to solve for 6.0.0. That's cool. I was just relaying the observation that the P6RE was fairly close to being able to implement Logical Programming, which several people

Re: Logic Programming with Rules (and Argument Patterns)

2005-03-09 Thread Larry Wall
On Wed, Mar 09, 2005 at 08:56:22AM -0700, Luke Palmer wrote: : I was decently insane last night. This generator stuff probably isn't : going anywhere. It's too abstract, and not precise enough, to be a : truly powerful part of the language. I suspect it's another one of the many things we just t

Re: Logic Programming with Rules (and Argument Patterns)

2005-03-09 Thread Luke Palmer
Rod Adams writes: > > > >You could do all of this with a library of rules. > > > > / $:= )> / > > > > > I don't think this does what I want. In this, &generate returns a rule > or string of some kind, matches the string being tested, captures what > matches, and then binds the capture to $.

Re: Logic Programming with Rules (and Argument Patterns)

2005-03-09 Thread Rod Adams
Luke Palmer wrote: Rod Adams writes: Or you could avoid the global modifier and write your tests in <( )> blocks instead... after all, that's what it's there for. I *knew* I had seen a syntax for that before... I just didn't see it when I scanned S05 for it. I still want the :z modifier for

Re: Argument Patterns

2005-03-09 Thread Thomas Sandlaß
HaloO Luke, you wrote: [..] The *method* is the one that knows everything, not the object. So definitions on subtypes of general types only check for those subtypes when dispatching to the methods defined in them. I stand corrected. Lax usage of Any is fair. Defining subtypes of general types and

Re: Argument Patterns

2005-03-09 Thread Luke Palmer
Thomas Sandlaà writes: > Luke Palmer wrote: > >But we always have enough knowledge to optimize the hell out of this, > >and they're not not handwavy "we can probably" optimizations. They're > >real, and they're pretty darn easy. > > I fully agree. But I like to add that a single 'where' on genera

Re: Logic Programming with Rules (and Argument Patterns)

2005-03-09 Thread Luke Palmer
/ $:= )> / How the rule is actually written is getting into some rule engine internal stuff, but we're making sure that the rule engine has enough hooks to do that. I think you'll be interested in where my 'Argument Patterns' proposal was going next, before I ran off

Re: Argument Patterns

2005-03-09 Thread Thomas Sandlaß
Luke Palmer wrote: But we always have enough knowledge to optimize the hell out of this, and they're not not handwavy "we can probably" optimizations. They're real, and they're pretty darn easy. I fully agree. But I like to add that a single 'where' on general types like Int, Str or even Any can s

Re: Argument Patterns

2005-03-09 Thread Luke Palmer
Leopold Toetsch writes: > Luke Palmer <[EMAIL PROTECTED]> wrote: > > > I think we should replace our multimethod system with a more general > > pattern matcher, a "variadic multimethod" system of sorts. Multimethods > > need to be variadic anyway, because we want pugs's quicksort example to > > w

Re: Argument Patterns

2005-03-09 Thread Leopold Toetsch
Luke Palmer <[EMAIL PROTECTED]> wrote: > I think we should replace our multimethod system with a more general > pattern matcher, a "variadic multimethod" system of sorts. Multimethods > need to be variadic anyway, because we want pugs's quicksort example to > work. I'd not say replace. The dispa

Re: Argument Patterns

2005-03-08 Thread Rod Adams
Autrijus Tang wrote: On Tue, Mar 08, 2005 at 04:55:28PM -0600, Rod Adams wrote: I thought Larry already declared that we are not making Perl act like ML (yet). And that was re: type inferencing, not re: pattern matching. :) Thanks, /Autrijus/ Sorry about that. Comcast has decided I only

Re: Argument Patterns

2005-03-08 Thread Autrijus Tang
On Tue, Mar 08, 2005 at 04:55:28PM -0600, Rod Adams wrote: > I thought Larry already declared that we are not making Perl act like ML > (yet). And that was re: type inferencing, not re: pattern matching. :) Thanks, /Autrijus/ pgp3tE8H37UB0.pgp Description: PGP signature

Re: Argument Patterns

2005-03-08 Thread Rod Adams
We can now define 'equal': sub equal ($x, $x) { 1 } sub equal ($x, $y) { "" } That's one of the MTOWs at least. The evaluation order of the patterns still needs to be thought out. I thought Larry already declared that we are not making Perl act like ML (yet). -- Rod Adams

Argument Patterns

2005-03-08 Thread Luke Palmer
x27;equal': sub equal ($x, $x) { 1 } sub equal ($x, $y) { "" } That's one of the MTOWs at least. The evaluation order of the patterns still needs to be thought out. There are more types of patterns. Types are patterns, and from this we see that following a pattern by

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

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

Patterns and junctions

2003-04-04 Thread Adam D. Lopresto
build an implementation that, for instance, has no preference among alternatives. 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

Re: possible bugs in Exegesis 5 code for matching patterns

2002-09-21 Thread Smylers
Steve Tolkin wrote: > { @$appendline =~ s// > I think this needs a backslash in front of the < symbol, and a space > after in_marker, i.e. it should be: > > { @$appendline =~ s//\

possible bugs in Exegesis 5 code for matching patterns

2002-09-20 Thread Tolkin, Steve
re is this code: { @$appendline =~ s///\</; That a small issue. But the following is more important because it strikes at the ease of using inheritance of grammars (i.e. patterns). In http://www.perl.com/pub/a/2002/08/22/exegesis5.html?page=5#different_diffs we see the code: rule fileinfo {