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

前端 未结 1 557
耶瑟儿~
耶瑟儿~ 2021-02-12 19:05

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:56

    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)
提交回复
热议问题