1000 LOC removed
There's not many things that make me happier than being able to remove existing code. These past few days have been quite good in that respect.
Previously I compiled a Rete Network from a Python AST by passing the rule function's AST to an ASTVisitor which returned a dictionary holding information about which nodes should be created. The dictionary was then passed to a method (construct_rete) which was in charge of creating the Rete Network and figuring out in what way the nodes should be connected.
That way of doing it turned out to be an ugly beast of complexity which managed to resist all of my attempts to make it simpler. I spent more than half a year trying before I binned it completely and yesterday I updated PyRete's SVN repository with the code I've got so far.
The approach I use now is that I pass the rule function's AST to an ASTVisitor which *directly* calls the Rete implementation. This way I don't have to go through all of the trouble of maintaining a dictionary with intermediate details and the result is that I've managed to get rid of about 1000 lines of code and the compilation process is more or less understandable.
"K-I-S-S. Keep it simple, stupid. Great advice. Hurts my feelings every time." -Dwight Schrute
1 kommentar:
Congrats! Sometimes indirection and abstractions get in the way :)
Skicka en kommentar