在绑定向量中评论Clojure

Gil*_*les 7 clojure

我注意到注释宏在绑定向量中不起作用,如下所示:

(let [a "first string"
      (comment 
      b (range 10)
      c [\a \b \c]
      )
      d "another string"]
  (str a " and " d))
Run Code Online (Sandbox Code Playgroud)

除了在注释块中的每一行前面放置一个分号外,还有其他方法可以在一个需要偶数个参数的绑定向量中注释几个绑定吗?

mty*_*aka 13

您可以使用#_阅读器宏,这将使读者完全忽略下一个表单:

(let [a "first string"
      #_( 
      b (range 10)
      c [\a \b \c]
      )
      d "another string"]
  (str a " and " d))
Run Code Online (Sandbox Code Playgroud)


drc*_*ode 5

mtyaka的答案是最好的,当然你也可以这样做:

(let [a "first string"
      _ (comment 
      b (range 10)
      c [\a \b \c]
      )
      d "another string"]
  (str a " and " d))
Run Code Online (Sandbox Code Playgroud)