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

前端 未结 1 1255
花落未央
花落未央 2021-02-12 20:09

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 20:24

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