Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
两者的区别是什么;及;;;在Clojure代码注释中?_Clojure_Comments_Marginalia - Fatal编程技术网

两者的区别是什么;及;;;在Clojure代码注释中?

两者的区别是什么;及;;;在Clojure代码注释中?,clojure,comments,marginalia,Clojure,Comments,Marginalia,之间有什么区别和在Clojure中启动注释时?我看到我的颜色不同,所以我假设有一些概念上的差异 我也看到了对他们的不同对待: ; Stripped entirely ;; Appears in text section of marginalia (defn foobar [] ; Appears in code section of marginalia output ;; Again, appears in code section of marginalia output

之间有什么区别
在Clojure中启动注释时?我看到我的颜色不同,所以我假设有一些概念上的差异

我也看到了对他们的不同对待:

; Stripped entirely
;; Appears in text section of marginalia
(defn foobar []
   ; Appears in code section of marginalia output
   ;; Again, appears in code section of marginalia output
   6)

我不确定(没有使用Clojure,以前从未听说过),但可能会有所帮助。

对这种语言没有意义<代码>
注释的读取器宏

也许有其他工具解析它们,但“在clojure中”它们是相同的;用于行末注释,如果不是您的意图,将以令人惊讶的方式缩进;;我通常不这么用

Clojure不在乎——任何一行都会被忽略;下线


我相信CL有一个传统,即使用越来越多的;说明更重要的评论/章节。

就口译员而言,没有区别。想想
作为不同的标题级别

以下是我的个人使用习惯:

;;;; Top-of-file level comments, such as a description of the whole file/module/namespace

;;; Documentation for major code sections (i.e. groups of functions) within the file.

;; Documentation for single functions that extends beyond the doc string (e.g. an explanation of the algorithm within the function)

; In-line comments possibly on a single line, and possibly tailing a line of code

从Clojure的角度来看,没有什么不同。我发现,
突出一点,但这只是我的意见


另一方面,Marginalia对它们的处理方式不同,因为有时注释应该保留在代码部分(例如许可证)中,并且这些注释被标记为
。这是一个任意的决定,将来可能会更改。

在emacs lisp模式中,包括clojure模式,
按照行首的约定进行格式化,并与任何其他行一样缩进<代码>
预计将在行尾使用,因此如果您在行首放置一个分号注释,希望它在当前上下文的缩进中使用制表符,emacs将不会执行您希望它执行的操作

例如:

(let [foo 1]
  ;; a comment
  foo) ; a comment
检查
的含义vs
在elisp中:由于Clojure压头基本相同,它将以类似方式处理它们。基本上,使用
如果您正在“在页边空白处”写一个长句/描述,它将跨越多行,但应被视为一个实体。他们的例子是:

(setq base-version-list                 ; there was a base
      (assoc (substring fn 0 start-vn)  ; version to which
             file-version-assoc-list))  ; this looks like
                                        ; a subversion
压头将确保这些压头排列在一起。相反,如果您想让几个不相关的单行注释彼此相邻,请使用

(let [x 99 ;; as per ticket #425
      y "test"] ;; remember to test this
  (str x y)) ;; TODO actually write this function

这些样式看起来与可变宽度字体完全不兼容。我希望Clojure社区没有采用列对齐的方式进行评论。fogus,注意alex miller关于emacs的评论。它是单缩进的;评论,但不是;;或如果您自己不使用emacs,您应该知道它的自动缩进方案的作用,因为您的许多目标用户都会这样做。我想我必须根据投票数将其标记为正确。一个外部参照会很好,但我想这是一种不成文的文化作为参考,《良好的Lisp编程风格》一书的作者Peter Norvig将此约定称为“接近标准”。那为什么不提单
在文档中@matanster链接是关于(注释)而不是;。但FTR最大的例子中的第二段确实讨论了一个问题;。用于服务器上的规范文档;读卡器宏检查