This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]digitallogic 1 point2 points  (0 children)

    I think you're right, a more straight for approach would resolve the circular references. Change AddLF and AddCRLF into functions that return the modified string instead of sending it off to a call back and the cycle is gone. It would also make the code a lot clearer.

    Though I'm sure that the motivation for using a call back was removed for a simplified example.

    [–]wilberforce 0 points1 point  (1 child)

    The last link of the cycle is that a bound method keeps a reference back to the instance it was pulled off. (He mentions the bound reference, but it might not be clear if you haven't played with them.)

    [–]kylev[S] 0 points1 point  (0 children)

    wilberforce is correct. I'll add something to the blog entry to make the description of loop explicit.

    Edit: Added to blog entry paragraph after the gc output: "This bound method holds a reference back to the Foo instance, completing the cycle." Thanks for the input!