Clojure head retention

后端 未结 3 548
梦谈多话
梦谈多话 2020-12-07 16:19

I\'m reading Clojure Programming book by O\'Reilly..

I came over an example of head retention. First example retains reference to d (I presume), so it d

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 16:29

    An important addition to the final example:

    (let [[t d] (split-with #(< % 12) (range 1e8))]
        [(count d)])
    

    Back to the final example, this doesn't work, because t is not actually used anywhere and unused locals are not handled by the locals clearing process.

    It's not the case anymore. Since Clojure 1.9 unused destructured locals are cleared. See CLJ-1744 for more details.

提交回复
热议问题