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::: BASICCOMMAND.COMcmd.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 shellsCobraPerlPythonRubySeed7Windows PowerShellPHPRMaple
% TeXPrologMATLAB,[9] ErlangS-LangVisual Prolog
// ActionScriptC (C99)C++C#DGoJavaJavaScriptObject Pascal (Delphi), Objective-CPHPScalaSASS
' Visual BasicVBScriptRealBasic
! Fortran, Basic Plus, Inform
; AutoHotkeyAutoItLispCommon LispClojureRebolScheme, many assemblers
-- EuphoriaHaskellSQLAdaAppleScriptEiffelLuaVHDLSGML
* 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 ~ cocomment ~comment ALGOL 68
/* */ ActionScript, AutoHotkey, C, C++, C#, D, Go, Java, JavaScript, Objective-C, PHP, PL/I, Scala (can be nested), SASS, SQL, Visual PrologCSS
#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, PascalSeed7ApplescriptOCaml (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)
#| |# LispSchemeRacket (can be nested in all three).
--[[ ]] Lua
" " Smalltalk
(comment ...) Clojure

各种语言的注释总结--from wiki的更多相关文章

  1. C语言程序注释风格

    良好编程习惯的养成对于一个程序员的发展非常重要,而注释对于一份程序来讲又是一个必不可少的组成部分,今天来研究一下C语言程序的注释风格. 注释是源码程序中非常重要的一部分,一般情况下,源程序有效注释量必 ...

  2. django模板语言的注释

    就像HTML或者Python,Django模板语言同样提供代码注释. 注释使用 {# #} : ? 1 {# This is a comment #} 注释的内容不会在模板渲染时输出. 用这种语法的注 ...

  3. C语言-删除注释

    C语言中的注释,不嵌套,一律使用/*   */的形式.不过双引号中的/*  */则不能算是注释. 以下是正确的代码 /* * ===================================== ...

  4. C语言进阶——注释符号12

    注释可能大认为非常简单,但是注释其实在C语言中很关键,来看下面一段对话. ---学生: 老师,我觉得注释没有必要深究,因为很简单,对程序功能也没有影响. ---老师: 注释是C语言最重要的工具,我们先 ...

  5. django 模板语言的注释操作

    Django在HTML里面书写的模板语言不能使用这种方法注释,这样注释实际依然有效 <!--{% if text %}--> 第一种使用模板标签{% comment %}注释,这是块注释 ...

  6. C语言讲义——注释

    注释 什么是注释?  --注释写在代码中的文字,不参与代码编译,不影响运行结果. 为什么要注释?--让代码可读性更强. C语言有两种注释: 单行注释 // 多行注释 /* */ 多行注释可以只有一行, ...

  7. 【学习笔记】【C语言】注释

    1. 什么是注释 1) 注释是在所有计算机语言中都非常重要的一个概念,从字面上看,就是注解.解释的意思 2) 注释可以用来解释某一段程序或者某一行代码是什么意思,方便程序员之间的交流.假如我写完一行代 ...

  8. jsp基础语言-jsp注释

    JSP注释可分为客户端注释和服务器端注释. 客户端注释:用户可通过浏览器中的源代码查看,且这种注释可以加入JSP表达式. 语法:<!-- 客户端注释[<%=表达式%>] --> ...

  9. python语言快捷注释

    1.注释单行 (1)方法1:直接在单行代码前边加 # (2)方法2:选中需要注释的代码,Ctrl+/ 即可注释 2.注释多行代码 选中想要注释的N行代码,直接Ctrl+/ 即可注释 3.取消注释多行代 ...

随机推荐

  1. HBase(五)HBase的API操作

    一.项目环境搭建 新建 Maven Project,新建项目后在 pom.xml 中添加依赖: <dependency> <groupId>org.apache.hbase&l ...

  2. CentOS 使用命令设置代理

    全局的代理设置, vim /etc/profile 添加下面内容 http_proxy = http://username:password@yourproxy:8080/ ftp_proxy = h ...

  3. mysql 函数group_concat()

    本文通过实例介绍了MySQL中的group_concat函数的使用方法,比如select group_concat(name) .MySQL中group_concat函数完整的语法如下:group_c ...

  4. 解决命令行运行python文件,出现No module named *** 报错问题

    有时候在一个项目中运行的时候,可能是之前已经mark成sources root 你自己忘记了, 于是就在命令行也执行python文件,然后就出现 No module named *** 等 相关你认为 ...

  5. react篇章-React State(状态)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

  6. Maven项目使用阿里云的Maven库

    Maven项目下载一些jar包非常慢,有时候一个项目能下一个上午,因此可以考虑使用阿里云的Maven库,因为是国内的,所以下载速度非常酷 单个项目使用阿里云的Maven库: pom文件中 <!- ...

  7. 【原创】MySQL CPU %sys高的案例分析(一)

    [现象] 最近关注MySQL CPU告警的问题时,发现有一种场景,有一些服务器最近都较频繁的出现CPU告警,其中的现象是 SYS CPU占比较高. 下面的截图来源于“MySQL CPU报警”采集的文件 ...

  8. [leetcode tree]104. Maximum Depth of Binary Tree

    求树的最大深度 class Solution(object): def maxDepth(self, root): if not root: return 0 left = self.maxDepth ...

  9. leetcode 无重复字符的最长子串 python实现

    这道题需要借助哈希查找key的O(n) 时间复杂度, 否则就会超时 初始化一个 哈希表\字典  dic 头指针start 初始为0 当前指针 cur 初始为0 最大长度变量 l 初始为0 用cur变量 ...

  10. [POJ1082]Calendar Game

    题目大意: 日历上博弈,从给定的日期,按照下述规则跳转日期: 1.跳到第二天: 2.调到下个月相同的日期(如果没有就不能跳转). 刚刚好跳到2001年11月4日的人胜,跳转时不能跳到2001年11月4 ...