On 15/07/2010 18:58, Karsten Wutzke wrote:
Hello,

this is obviously a Python OO question:

Since Python isn't stringly typed, single-dispatch isn't available per
se. So is the "double-dispatch" Visitor pattern, which is usually used
in OO systems to implement code generators. So, what is the de facto
method in Python to handle source code generation?

Karsten
I'm baffled. Not by what you mean by stringly, but....

What feature of Python stops you writing the three parts of the visitor pattern:

IIRC you need:

A tree walker that creates the visitor and walks the tree calling
    node.visitFrom(visitor)
on each one in the required order.

The  visitfrom(aVisitor) routines in each node type that calls
    aVisitor.visitedMyNodeType(self)
where MyNodeType is, naturally different for each node type!

All the
   def visitedNodeType(aNode):  routines in visitor to generate the code.

Simples! No? :)

Ian




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to