; 之间有什么区别?和 ;;在 Clojure 代码注释中?
在 Clojure 中开始注释时 ;
和 ;;
有什么区别?我发现我的文本编辑器对它们的颜色不同,所以我假设理论上存在一些差异。
我还发现 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)
What is the difference between ;
and ;;
when starting a comment in Clojure? I see that my text editor colours them differently, so I'm assuming there is notionally some difference.
I also see that Marginalia treats them differently:
; 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
对于口译员来说,没有什么区别。将
;
;;
;;;
和;;;;
视为不同的标题级别。这是我个人的使用习惯:
There is no difference as far as the interpreter is concerned. Think of
;
;;
;;;
and;;;;
as different heading levels.Here is my personal use convention:
查看 官方说明
的含义;< elisp 中的 /code> 与
;;
:由于 Clojure 压头基本相同,因此会以类似方式对待它们。基本上,如果您要在“页边空白处”编写一个长句子/描述,该句子/描述将跨越多行,但应被视为单个实体,请使用;
。他们的例子是:压头将确保它们彼此相邻排列。相反,如果您想在彼此旁边添加多个不相关的单行注释,请使用
;;
。Check out the official description of the meaning of
;
vs;;
in elisp: since the Clojure indenter is basically the same, it will treat them similarly. Basically, use;
if you are writing a long sentence/description "in the margins" that will span multiple lines but should be considered a single entity. Their example is:The indenter will make sure those stay lined up next to each other. If, instead, you want to make several unrelated single-line comments next to each other, use
;;
.Emacs;用于行尾注释,如果这不是您的意图,则会以令人惊讶的方式缩进。 ;;不是这样,所以我通常使用;;。
Clojure 并不关心 - ; 中的任何行都会被忽略。至停产。
我相信 CL 有一个传统,即使用越来越多的 ;指示更重要的评论/部分。
Emacs ; to be used for end-of-line comments and will indent in surprising ways if that is not your intent. ;; does not so I usually use ;;.
Clojure doesn't care - any line is ignored from the ; to EOL.
I believe there is a tradition in CL of using increasing numbers of ; to indicate more important comments/sections.
对于语言来说没有任何意义。
;
是comment
的阅读器宏也许其他工具可以解析它们,但“在 clojure 内”它们是相同的。
no meaning for the language.
;
is a reader macro forcomment
perhaps other tools parse them but "within clojure" they are the same.
从 Clojure 的角度来看没有什么区别。我发现
;;
比;
突出一点,但这只是我的意见。另一方面,边注对它们的处理方式有所不同,因为有时注释应该保留在代码部分(例如许可证),并且这些注释会用
;
标记。这是一个任意决定,将来可能会改变。There is no difference from a Clojure-perspective. I find that
;;
stands out a little better than;
, but that's only my opinion.Marginalia on the other hand treats them differently because there are times when a comment should remain in the code section (e.g. license) and those are flagged with
;
. This is an arbitrary decision and may change in the future.在包括 clojure 模式在内的 emacs lisp 模式中,
;;
的格式遵循位于行开头的约定,并根据上下文与任何其他行一样缩进。;
预计在行尾使用,因此,如果您在行首放置单分号注释并希望它跳到行尾,emacs 将不会执行您想要的操作当前上下文的缩进。例子:
In emacs lisp modes including clojure-mode,
;;
is formatted with the convention of being at the beginning of a line, and indented as as any other line, based on the context.;
is expected to be used at the end of a line, so emacs will not do what you want it to if you put a single-semicolon comment at the beginning of a line expecting it to tab to the indentation for the present context.Example:
我不确定(没有使用过 Clojure,以前从未听说过),但是
I'm not sure (not used Clojure and never heard of this before), but this thread might help.