在绑定向量中注释Clojure

7
我注意到,在绑定向量中,注释宏无法正常工作,如下所示:
(let [a "first string"
      (comment 
      b (range 10)
      c [\a \b \c]
      )
      d "another string"]
  (str a " and " d))

除了在注释块中的每一行前面放置一个分号之外,还有什么其他方法可以对期望偶数个参数的绑定向量中的多个绑定进行注释?

2个回答

13
你可以使用#_读取宏,这将使读取器完全忽略下一个表单:
(let [a "first string"
      #_( 
      b (range 10)
      c [\a \b \c]
      )
      d "another string"]
  (str a " and " d))

太棒了!谢谢你这么快的回复! - Giles

5

mtyaka的回答是最好的,但是你也可以这样做:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接