在;中开始评论时,;;和Clojure有什么不同?我发现我的text editor对它们的颜色不同,所以我假设在理论上是有一些不同的。
我还看到Marginalia对待它们的方式是不同的:
; 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)发布于 2011-02-23 06:50:19
就解释器而言,这没有区别。将;、;;、;;;和;;;;视为不同的标题级别。
以下是我的个人使用约定:
;;;; 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发布于 2012-01-12 03:01:49
查看elisp中;与;;含义的official description:由于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发布于 2011-02-23 06:44:39
Emacs;用于行尾注释,如果这不是您的本意,它将以令人惊讶的方式缩进。;;不是,所以我通常用;;。
Clojure并不关心--从;到EOL,任何行都会被忽略。
我相信在CL中有一个传统,使用越来越多的;来表示更重要的评论/部分。
https://stackoverflow.com/questions/5084191
复制相似问题