From jeremy at alum.mit.edu Fri Oct 31 14:44:08 2003 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri Oct 31 14:46:55 2003 Subject: [Compiler-sig] proposed change to compiler package Message-ID: <1067629448.24165.150.camel@localhost.localdomain> The top-level walk() function in the compiler package returns the visitor object that is passed to walk. I'd like to change it to return the result of the top-level dispatch() or visit() call. Right now, visitor methods can return a value, which is useful for a visit() call that is internal to a visitor, but can't return it to the caller of walk(). The current return value is pretty useless, since the caller of walk() must pass the visitor as one of the arguments. That is, walk() returns one of its arguments. The change might break some code, but only in a trivial way, and it will make possible to write visitors that don't have any state-- simple combinators. Example: class NameVisitor: """Compute a dotted name from an expression.""" def visitGetattr(self, node): return "%s.%s" % (self.visit(node.expr), node.attrname) def visitName(self, node): return node.name Jeremy