2006-09-16

Duck typing and Rete

Peter and Chimezie have both commented my last post about the Alpha Network implementation and the problem with ObjectTypeNodes and duck typing.

Peter even suggested a way of implementing an ObjectTypeNode based on slots. Chimezie OTOH claims to have incorporated the ObjectTypeNode within the rule language of the latest version of FuXi. I haven't had the time to check out what he's done yet, but I will. I'll post about that later.

Let's get back to the problem at hand: Duck typing. While Peter's suggested implementation sure takes care of using minimal effort to find out where an object matches. The problem is still that the whole idea of duck typing, translated to the Rete situation, is that everywhere an object matches the expected API - it will be used.

The whole point of having the ObjectTypeNode seems to be to reduce the number of evaluations. With duck typing, no such coarse grained filtering can be performed. You'd have to look into an object's details before you can decide whether or not it matches. And, would you really write your rules like that?

My plan at the moment is to use PyPy for the Shell part of my implementation. By using PyPy I can also add things like static typing in the rule definitions. I think that would most certainly be the easiest way out.

At the moment I'm implementing two different versions of the Alpha Network. One using static typing (ObjectTypeNode) and one using duck typing (similar to Peter's design). It's going to be very interesting to try and match some large sets of facts in each of them and see what happens.

Inga kommentarer: