首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Clojure代码注释中;和;有什么区别?

在Clojure代码注释中;和;有什么区别?
EN

Stack Overflow用户
提问于 2011-02-23 05:29:17
回答 7查看 15.4K关注 0票数 75

;中开始评论时,;;和Clojure有什么不同?我发现我的text editor对它们的颜色不同,所以我假设在理论上是有一些不同的。

我还看到Marginalia对待它们的方式是不同的:

代码语言:javascript
复制
; 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)
EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2011-02-23 06:50:19

就解释器而言,这没有区别。将;;;;;;;;;;视为不同的标题级别。

以下是我的个人使用约定:

代码语言:javascript
复制
;;;; 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
票数 86
EN

Stack Overflow用户

发布于 2012-01-12 03:01:49

查看elisp中;;;含义的official description:由于Clojure缩进器基本上是相同的,因此它将以类似的方式对待它们。基本上,如果你正在写一个很长的句子/描述“在页边空白处”,会跨越多行,但应该被认为是一个单独的实体,那么就应该使用;。他们的例子是:

代码语言:javascript
复制
(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

缩进器将确保它们彼此排成一排。相反,如果您想要彼此相邻地创建几个不相关的单行注释,请使用;;

代码语言:javascript
复制
(let [x 99 ;; as per ticket #425
      y "test"] ;; remember to test this
  (str x y)) ;; TODO actually write this function
票数 32
EN

Stack Overflow用户

发布于 2011-02-23 06:44:39

Emacs;用于行尾注释,如果这不是您的本意,它将以令人惊讶的方式缩进。;;不是,所以我通常用;;。

Clojure并不关心--从;到EOL,任何行都会被忽略。

我相信在CL中有一个传统,使用越来越多的;来表示更重要的评论/部分。

票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5084191

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档