Why no destructing in def form?

后端 未结 4 2104
北恋
北恋 2021-02-18 20:10

In a let form (Clojure here) I can doing something like

(let [[u s v] (svd A)] 
   (do-something-with u v))

where svd

4条回答
  •  不知归路
    2021-02-18 21:07

    def is basically the constructor for Vars. The first argument is the symbol that names the Var. It takes that symbol and returns a Var for that symbol. Destructuring would change these semantics.

    You could write a macro that does it, though.

提交回复
热议问题