On Thursday, March 31, 2022 at 3:52:55 PM UTC-5 Edward K. Ream wrote:
> After looking at leoAst.py with fresh eyes, the following Aha's emerged: There is a third Aha: parent/child (or any other threading links) are almost useless! No amount of links will suffice to drive a tree traversal. It's not enough to know in what order to visit tree nodes. One must also remember the (coroutine) state as well! Recursive descent, generators and the new iterative scheme all remember the state. Links do not. End of story. My long-time fixation on tree links confused and mislead me for decades. I'm glad to put this delusion to rest. Now I see why ast.walk is so useful: often it *doesn't matter* how one discovers nodes of a particular type. For example, Fstringify.visit uses none of the links that were so carefully (and uselessly) created. It only uses the already existing links in an ast.BinOp node whose operator (node.op) is '%'. Otoh, we can't *just* use ast.walk in the Fstringify class. Fstringify.make_fstring *does* use the list of tokens associated with the BinOp node. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/20006656-0268-4754-b426-2c79c76414e9n%40googlegroups.com.
