[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Wed Jun 7 02:30:19 BST 2023


https://bugs.libre-soc.org/show_bug.cgi?id=1094

--- Comment #50 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
https://medium.com/design-patterns-in-python/visitor-pattern-b9227759d6be

ah this is really clear and very nice: it clearly accentuates and
illustrates the difference between *visiting* and *accepting*.

they call it:

    class IVisitor(metaclass=ABCMeta):
        "An interface that custom Visitors should implement"

    class IVisitable(metaclass=ABCMeta):
        """
        An interface the concrete objects should implement that allows
        the visitor to traverse a hierarchical structure of objects
        """

Visitor and Visitable.  ha!  that's the phrases i was looking for.

* at the base class of *all* the insndb classes should be an
  accept(self, visitor) function

* that function should, like python 2.7 ast.py, be capable of
  doing *full* recursive self-introspection, based on the
  insndb fields, *not* based on explicit implementation of
  accept() in *every* single insndb class (of which we have...
  100?)

the only thing "bad" about the example there is that IVisitor.visit()
is a static method.  but there is probably a good reason for it?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list