各种语言的注释总结--from wiki
Comments can be classified by:
- style (inline/block)
- parse rules (ignored/interpolated/stored in memory)
- recursivity (nestable/non-nestable)
- uses (docstrings/throwaway comments/other)
Inline comments[edit]
Inline comments are generally those that use a newline character to indicate the end of a comment, and an arbitrary delimiter or sequence of tokensto indicate the beginning of a comment.
Examples:
Symbol | Languages |
---|---|
C |
Fortran 77 and earlier; the 'C' must be in column 1 of a line to indicate a comment. |
REM , :: , : |
BASIC, COMMAND.COM, cmd.exe, batch files |
NB. |
J; from the (historically) common abbreviation Nota bene, the Latin for "note well". |
⍝ |
APL; the mnemonic is the glyph (jot overstruck with shoe-down) resembles a desk lamp, and hence "illuminates" the foregoing. |
# |
Bourne shell and other UNIX shells, Cobra, Perl, Python, Ruby, Seed7, Windows PowerShell, PHP, R, Maple |
% |
TeX, Prolog, MATLAB,[9] Erlang, S-Lang, Visual Prolog |
// |
ActionScript, C (C99), C++, C#, D, Go, Java, JavaScript, Object Pascal (Delphi), Objective-C, PHP, Scala, SASS |
' |
Visual Basic, VBScript, RealBasic |
! |
Fortran, Basic Plus, Inform |
; |
AutoHotkey, AutoIt, Lisp, Common Lisp, Clojure, Rebol, Scheme, many assemblers |
-- |
Euphoria, Haskell, SQL, Ada, AppleScript, Eiffel, Lua, VHDL, SGML |
* |
COBOL (if fixed-form and * in column 7), PAW, many assemblers, Fortran (if fixed-form and * in column 1) |
|| |
Curl |
" |
Vimscript |
\ |
Forth |
Block comments[edit]
Block comments are generally those that use a delimiter to indicate the beginning of a comment, and another delimiter to indicate the end of a comment. In this context, whitespace and newline characters are not counted as delimiters.
Examples:
Symbol | Languages |
---|---|
¢ ~ ¢ , # ~ # , co ~ co , comment ~comment |
ALGOL 68 |
/* */ |
ActionScript, AutoHotkey, C, C++, C#, D, Go, Java, JavaScript, Objective-C, PHP, PL/I, Scala (can be nested), SASS, SQL, Visual Prolog, CSS |
#cs #ce |
AutoIt |
/+ +/ |
D (can be nested) |
/# #/ |
Cobra (can be nested) |
<# #> |
Powershell |
=begin =cut |
Perl |
=begin =end |
Ruby |
#<tag></code> <code>#</tag> |
S-Lang |
{- -} |
Haskell (can be nested) |
(* *) |
Object Pascal (Delphi), ML, Mathematica, Pascal, Seed7, Applescript, OCaml (can be nested), Standard ML (can be nested), Maple, Newspeak |
{ } |
Object Pascal (Delphi), Pascal |
|# #| |
Curl |
%{ %} |
MATLAB[9] (the symbols must be in a separate line) |
#| |# |
Lisp, Scheme, Racket (can be nested in all three). |
--[[ ]] |
Lua |
" " |
Smalltalk |
( comment ...) |
Clojure |
各种语言的注释总结--from wiki的更多相关文章
- C语言程序注释风格
良好编程习惯的养成对于一个程序员的发展非常重要,而注释对于一份程序来讲又是一个必不可少的组成部分,今天来研究一下C语言程序的注释风格. 注释是源码程序中非常重要的一部分,一般情况下,源程序有效注释量必 ...
- django模板语言的注释
就像HTML或者Python,Django模板语言同样提供代码注释. 注释使用 {# #} : ? 1 {# This is a comment #} 注释的内容不会在模板渲染时输出. 用这种语法的注 ...
- C语言-删除注释
C语言中的注释,不嵌套,一律使用/* */的形式.不过双引号中的/* */则不能算是注释. 以下是正确的代码 /* * ===================================== ...
- C语言进阶——注释符号12
注释可能大认为非常简单,但是注释其实在C语言中很关键,来看下面一段对话. ---学生: 老师,我觉得注释没有必要深究,因为很简单,对程序功能也没有影响. ---老师: 注释是C语言最重要的工具,我们先 ...
- django 模板语言的注释操作
Django在HTML里面书写的模板语言不能使用这种方法注释,这样注释实际依然有效 <!--{% if text %}--> 第一种使用模板标签{% comment %}注释,这是块注释 ...
- C语言讲义——注释
注释 什么是注释? --注释写在代码中的文字,不参与代码编译,不影响运行结果. 为什么要注释?--让代码可读性更强. C语言有两种注释: 单行注释 // 多行注释 /* */ 多行注释可以只有一行, ...
- 【学习笔记】【C语言】注释
1. 什么是注释 1) 注释是在所有计算机语言中都非常重要的一个概念,从字面上看,就是注解.解释的意思 2) 注释可以用来解释某一段程序或者某一行代码是什么意思,方便程序员之间的交流.假如我写完一行代 ...
- jsp基础语言-jsp注释
JSP注释可分为客户端注释和服务器端注释. 客户端注释:用户可通过浏览器中的源代码查看,且这种注释可以加入JSP表达式. 语法:<!-- 客户端注释[<%=表达式%>] --> ...
- python语言快捷注释
1.注释单行 (1)方法1:直接在单行代码前边加 # (2)方法2:选中需要注释的代码,Ctrl+/ 即可注释 2.注释多行代码 选中想要注释的N行代码,直接Ctrl+/ 即可注释 3.取消注释多行代 ...
随机推荐
- mongo 常用操作命令
表的帮助,格式:db.表名.help() db.test.find({id:10}) 返回test数据集ID=10的数据集 db.test.find({id:10}).count ...
- 【LOJ】#2072. 「JSOI2016」独特的树叶
题解 干脆题解套题解好了 毕竟我的hash方法是抄小迪的 https://www.cnblogs.com/RabbitHu/p/9165770.html 小迪太巨了%%% 之前模数是八位的WA了几个点 ...
- Educational Codeforces Round 44 (Rated for Div. 2) F - Isomorphic Strings
F - Isomorphic Strings 题目大意:给你一个长度为n 由小写字母组成的字符串,有m个询问, 每个询问给你两个区间, 问你xi,yi能不能形成映射关系. 思路:这个题意好难懂啊... ...
- HTTP协议--请求与响应
1.简介 HTTP 是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于分布式超媒体信息系统.它于1990 年提出,经过几年的使用与发展,得到不断地完善和扩展.目前在WWW 中使用的是HT ...
- 牛客练习赛1 C - 圈圈
链接:https://www.nowcoder.com/acm/contest/2/C来源:牛客网 题目描述 shy有一个队列a[1], a[2],…,a[n].现在我们不停地把头上的元素放到尾巴上. ...
- react篇章-事件处理
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...
- pyinstaller 打包错误集锦
最近在用 pyinstaller 打包项目的时候遇到如下错误: RecursionError: maximum recursion depth exceeded 解决方案 执行 pyinstaller ...
- UVA - 11995 - I Can Guess the Data Structure! STL 模拟
There is a bag-like data structure, supporting two operations: 1 x Throw an element x into the bag. ...
- CLR基础
一.各个语言的长处 ①非托管C/C++可对系统进行低级控制.可完全按照自己的想法管理内存,必要时方便地创建线程②使用Microsoft Visual Basic 6.0可以快速生成UI应用程序,并可以 ...
- 机器学习之路: python 线性回归LinearRegression, 随机参数回归SGDRegressor 预测波士顿房价
python3学习使用api 线性回归,和 随机参数回归 git: https://github.com/linyi0604/MachineLearning from sklearn.datasets ...