Re: AST observations
[email protected] (Jeremy Hylton) Fri, 19 Apr 2002 10:59:39 -0400
| Newsgroups | gmane.comp.python.compiler |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "FB" == Finn Bock <[email protected]> writes: FB> [Jeremy] >> It might be clearer to merge the walker and the visitor into a >> single class using inheritance. (I think the Walkabout variant >> described by Palsberg and Jay does this, >> cf. http://citeseer.nj.nec.com/palsberg97essence.html.) FB> Yes, and so does the the Visitor pattern they describe in FB> 2.3. Based on the performance measurement in chapter 4, at least FB> I hope you understand why I argue for a static double dispatch FB> Visitor instead of a dynamic dispatching Walkabout pattern. The FB> added flexibility of dynamic dispatch is pure YAGNI for FB> me. Since I can control the code generated for each AST node, it FB> would be plain wrong not to add an 'accept' method. Yes, indeed. I wasn't trying to do anything efficiently, and I definitely did not care about Java performance when I wrote all the code. For use in the core of Jython or CPython, however, performance is an important consideration. It makes complete sense to generate all the visitor dispatch code statically for Java and C. (I wonder how much performance difference it makes for 100% pure Python.) Jeremy