各种语言的注释总结--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::: 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

本文转自二郎三郎博客园博客,原文链接:http://www.cnblogs.com/haore147/p/3606079.html,如需转载请自行联系原作者
相关文章
|
23天前
|
自然语言处理 算法 前端开发
C++与Doxygen:精通代码文档化之道
C++与Doxygen:精通代码文档化之道
48 0
|
8月前
|
PHP
PHP - Laravel Blade模板注释 {{-- 注释 --}} 与 <!-- 注释 --> 的区别
PHP - Laravel Blade模板注释 {{-- 注释 --}} 与 <!-- 注释 --> 的区别
62 0
|
7月前
|
Rust 前端开发 编译器
Rust的注释与文档
Rust的注释与文档
35 0
|
8月前
|
Java API 开发工具
EditPlus的使用和注释与API文档等
EditPlus的使用和注释与API文档等
59 0
|
8月前
|
JSON 自然语言处理 JavaScript
go 语言实战入门案例之命令行排版词典
go 语言实战入门案例之命令行排版词典
50 0
Go 开发常用操作技巧--字符串
Go 语言字符串的字节使用的是UTF-8编码,是一种变长的编码方式。使用1~4个字节表示一个符号,根据不同的符号而变化字节长度。
202 0
Go 开发常用操作技巧--字符串
|
Java Maven Android开发
Gradle 使用技巧(七) - 10分钟将快速开源 Jitpack 与增加中文注释
引言 作为一个开发者,最自豪的事情就是自己的努力得到了别人的赞赏。这一次就通过一个简短的系列:如何在最简短的时间内将自己的lib上传到中央仓库供其他人下载,并且增加中文源码注释。
1314 0