Some more thoughts on pattern matching
I've just checked in the code for a PatternMatchingNode and a SingleNotMatchNode. I'm still not sure the implementation I've done is a good idea (rulecompiler.py is coming close to 1000 lines of not-so-simple-code). I went with:
>>> @pyRete.RuleWhich, at least, won't raise a SyntaxError outside of pyRete context. In Clips, pattern matching looks more "natural":
... def some_rule(obj = SomeObject):
... if obj(foo == 1, bar == 2, baz == 3):
... pass
(defrule some-ruleUnfortunately, there's no way to *not* bind an object to a variable in pyRete so a more correct Clips translation is:
(SomeObject (foo 1) (bar 2) (baz 3))
=> )
(defrule some-ruleWhich still looks a lot better than what I've done :-)
?obj <- (SomeObject (foo 1) (bar 2) (baz 3)) => )
However, looking at the big picture. I really *love* the fact that many of my rules now are shorter and simpler and I guess that's what it's all about.
Inga kommentarer:
Skicka en kommentar