sdxpy icon indicating copy to clipboard operation
sdxpy copied to clipboard

Section 4.2: Rethinking

Open AugustH opened this issue 4 months ago • 0 comments

Null objects must be at the end of the matching chain, i.e., their rest must be None, so we remove the rest parameter from the class's constructor and pass None up to the parent constructor every time.

But the code does NOT call the parent constructor at all.

    class Null(Match):
        def __init__(self):
            self.rest = None

Calling with

    class Null(Match):
        def __init__(self):
            super().__init__(None)

does not work either: this would create a new Null() and recurses endless.

Actually the value self.rest is never used, so it could be anything. IMHO: Setting the value of None breaks the class invariant: because of the if in the constructor the value is never None. If this classes get more methods this will break and somebody has to keep all the broken parts 😁.

AugustH avatar Sep 25 '24 16:09 AugustH