Why is it called "open (or closed) recursion?

后端 未结 1 1624
小蘑菇
小蘑菇 2021-02-12 18:44

I found some explanations of open/closed recursion, but I do not understand why the definition contains the word \"recursion\", or how it compares with dynamic/static dispatchin

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-12 19:31

    I tried to start writing an answer here and then ended up writing an entire blog post about it. The TL;DR is:

    So, if you compare a real object-oriented language to a simpler language with just structures and functions, the differences are:

    • All of the methods can see and call each other. The order they are defined doesn’t matter since their definitions are “simultaneous” or mutually recursive.
    • The base methods have access to the derived receiver object (i.e. this or self in other languages) so they don’t close over just each other. They are open to overridden methods.

    Thus: open recursion.

    0 讨论(0)
提交回复
热议问题