[PEAK] Issues with peak.rules predicates
Phillip J. Eby
pje at telecommunity.com
Sat Feb 9 18:22:14 EST 2008
At 05:32 PM 2/9/2008 -0500, rdmurray at bitdance.com wrote:
>The first place I am getting an error arises from this line:
>
>@checksemantics.when("DO is None and IDO is None and not V.isVIT")
>
>The problem is that this rule is not firing, when under RuleDispatch
>it does. My guess is that the problem is V.isVIT. The value of V.isVIT
>is produced by a __getattr__. I'm guessing that V.isVIT is
>evaluating to True when it should be False. Is this a limitation
>of peak.rules?
No. It's probably a bug of some sort. If you can reduce the problem
to a short example, I should be able to fix it pretty easily.
One point, however: RuleDispatch turns "x is None" into
"isinstance(x,NoneType)", while PEAK-Rules currently does
not. However, if this were the direct source of the problem, I would
expect you to be seeing an AmbiguousMethods error.
>As long as I'm writing, I'm also wondering if there is a simple way to
>see what the dispatch mechanism is doing, of seeing what it is evaluating
>the various values to be.
Not exactly. But in the couple of bugs people have found so far,
it's usually the dispatch *tree* that's at fault, and that can be
found by examining the GF's .func_code.co_consts and looking for the
first tuple. Deciphering what that tuple *means* is a bit more
complex, however. :)
> While developing with RuleDispatch I often
>wished I had a way to get a trace of the dispatch machinery in action,
>but I was always able to get my code working so I never got around to
>asking about it :)
The indexing and tree-building framework in PEAK-Rules is flexible
enough that one could probably create a "pretty-printing" engine to
dump out a logical representation of the dispatch tree, or perhaps
generate equivalent Python source code that could then be stepped
through. Check out Indexing.txt and Predicates.txt in the source, if
you're curious.
>--David
>_______________________________________________
>PEAK mailing list
>PEAK at eby-sarna.com
>http://www.eby-sarna.com/mailman/listinfo/peak
More information about the PEAK
mailing list