Why don't purely functional languages use reference counting?

前端 未结 6 1213
忘了有多久
忘了有多久 2021-02-02 06:27

In purely functional languages, data is immutable. With reference counting, creating a reference cycle requires changing already created data. It seems like purely functional la

6条回答
  •  面向向阳花
    2021-02-02 06:36

    Consider this allegory told about David Moon, an inventor of the Lisp Machine:

    One day a student came to Moon and said: "I understand how to make a better garbage collector. We must keep a reference count of the pointers to each cons."

    Moon patiently told the student the following story:

    "One day a student came to Moon and said: 'I understand how to make a better garbage collector...

提交回复
热议问题