fbpx
Wikipedia

This comparison of programming languages compares the features of language syntax (format) for over 50 computer programming languages.

Contents

Programming language expressions can be broadly classified into four syntax structures:

prefix notation
  • Lisp (* (+ 2 3) (expt 4 5))
infix notation
suffix, postfix, or Reverse Polish notation
math-like notation
  • TUTOR (2 + 3)(45) $$ note implicit multiply operator

When the Programming Languages (usually Algol descendants) has statements they typically have conventions for:

  • statement separators;
  • statement terminators; and
  • line continuation

A statement separator is used to demarcate boundaries between two separate statements. A statement terminator is used to demarcate the end of an individual statement. Languages that interpret the end of line to be the end of a statement are called "line-oriented" languages.

"Line continuation" is a convention in line-oriented languages where the newline character could potentially be misinterpreted as a statement terminator. In such languages, it allows a single statement to span more than just one line.

Language Statement separator-terminator Secondary separator-terminator
ABAP period separated
Ada semicolon terminated
ALGOL semicolon separated
ALGOL 68 semicolon and comma separated
APL newline terminated [Direct_function ⋄] separated Secondary
AppleScript newline terminated
AutoHotkey newline terminated
BASIC newline terminated colon separated
Boo newline terminated
C semicolon terminates statements comma separates expressions
C++ semicolon terminates statements comma separates expressions
C# semicolon terminated
COBOL whitespace separated, sometimes period separated, optionally separated with commas and semi-colons.
Cobra newline terminated
CoffeeScript newline terminated
CSS semicolon separated
D semicolon terminated
Eiffel newline terminated semicolon
Erlang colon separated, period terminated
F# newline terminated semicolon
Fortran newline terminated semicolon
Forth semicolons terminate word definitions. space terminates word use
GFA BASIC newline terminated
Go semicolon separated (inserted by compiler)
Haskell (in do-notation) newline separated
Haskell (in do-notation, when braces are used) semicolon separated
Java semicolon terminated
JavaScript semicolon separated (but sometimes implicitly inserted on newlines)
Kotlin semicolon separated (but sometimes implicitly inserted on newlines)
Lua whitespace separated (semicolon optional)
Mathematica
also called Wolfram
semicolon separated
MATLAB newline terminated semicolon or comma
MUMPS
also called M
newline terminates line-scope, the closest to a "statement" that M has. a space separates/teminates a command, allowing another command to follow.
Nim newline terminated
Object Pascal also (Delphi) semicolon separated
Objective-C semicolon terminated
OCaml semicolon separated
Pascal semicolon separated
Perl semicolon separated
PHP semicolon terminated
Pick Basic newline terminated semicolon separated
PowerShell newline terminated semicolon separated
Prolog comma separated (conjunction), semicolon separated (disjunction), period terminated (clause)
Python newline terminated semicolon
R newline terminated semicolon
Raku semicolon separated
Red whitespace separated
Ruby newline terminated semicolon
Rust semicolon terminates statements comma separates expressions
Scala newline terminated (semicolon optional) semicolon
Seed7 semicolon separated (semicolon termination is allowed)
Simula semicolon separated
S-Lang semicolon separated
Smalltalk period separated
Standard ML semicolon separated
Swift semicolon separated (inserted by compiler)
Visual Basic newline terminated colon separated
Visual Basic .NET newline terminated colon separated
Wolfram Language semicolon separated
Xojo newline terminated
Language Statement separator-terminator Secondary separator-terminator

Line continuation

Line continuation is generally done as part of lexical analysis: a newline normally results in a token being added to the token stream, unless line continuation is detected.

Whitespace – Languages that do not need continuations
  • Ada – Lines terminate with semicolon
  • C# – Lines terminate with semicolon
  • JavaScript – Lines terminate with semicolon (which may be inferred)
  • Lua
  • OCaml
Ampersand as last character of line
Backslash as last character of line
Backtick as last character of line
Hyphen as last character of line
Underscore as last character of line
Ellipsis (as three periods–not one special character)
  • MATLAB: The ellipsis token need not be the last characters on the line, but any following it will be ignored. (In essence, it begins a comment that extends through (i.e. including) the first subsequent newline character. Contrast this with an inline comment, which extends until the first subsequent newline.)
Comma delimiter as last character of line
  • Ruby (comment may follow delimiter)
Left bracket delimiter as last character of line
Operator as last object of line
  • Ruby (comment may follow operator)
Operator as first character of continued line
  • AutoHotkey: Any expression operators except ++ and --, as well as a comma or a period
Backslash as first character of continued line
Some form of inline comment serves as line continuation
Character position
  • Fortran 77: A non-comment line is a continuation of the previous non-comment line if any non-space character appears in column 6. Comment lines cannot be continued.
  • COBOL: String constants may be continued by not ending the original string in a PICTURE clause with ', then inserting a - in column 7 (same position as the * for comment is used.)
  • TUTOR: Lines starting with a tab (after any indentation required by the context) continue the previous command.
[End and Begin] using normal quotes
  • C and C++ preprocessor: The string is ended normally and continues by starting with a quote on the next line.
This section needs expansion. You can help by adding to it.(December 2009)

To import a library is a way to read external, possibly compiled, routines, programs or packages. Imports can be classified by level (module, package, class, procedure,...) and by syntax (directive name, attributes,...)

File import
Package import
Class import
  • from module import class Python
  • import package.class Java, MATLAB, kotlin
  • import class from "modname";, JavaScript
  • import {class} from "modname";, JavaScript
  • import {class as altname} from "modname";JavaScript
  • import package.class, Scala
  • import package.{ class1 => alternativeName, class2 }, Scala
  • import package._Scala
  • use Namespace\ClassName;, PHP
  • use Namespace\ClassName as AliasName; PHP
Procedure/function import
  • from module import function Python:
  • import package.module : symbol;, D:
  • import package.module : altsymbolname = symbol; D:
  • import Module (function) Haskell:
  • import function from "modname";, JavaScript:
  • import {function} from "modname";, JavaScript:
  • import {function as altname} from "modname";JavaScript:
  • import package.function MATLAB:
  • import package.class.function, Scala:
  • import package.class.{ function => alternativeName, otherFunction }Scala:
  • use Module ('symbol');Perl:
  • use function Namespace\function_name;, PHP:
  • use Namespace\function_name as function_alias_name; PHP:
  • use module::submodule::symbol;, Rust:
  • use module::submodule::{symbol1, symbol2};, Rust:
  • use module::submodule::symbol as altname; Rust:
Constant import
  • use const Namespace\CONST_NAME; PHP

The above statements can also be classified by whether they are a syntactic convenience (allowing things to be referred to by a shorter name, but they can still be referred to by some fully qualified name without import), or whether they are actually required to access the code (without which it is impossible to access the code, even with fully qualified names).

Syntactic convenience
  • import package.* Java
  • import package.class Java
  • open module OCaml
Required to access code
  • import altname "package/name" Go
  • import altname from "modname";JavaScript
  • import modulePython

A block is a notation for a group of two or more statements, expressions or other units of code that are related in such a way as to comprise a whole.

Braces (a.k.a. curly brackets) { ... }
Parentheses ( ... )
Square brackets [ ... ]
  • Smalltalk (blocks are first class objects. a.k.a. closures)
begin ... end
do ... end
do ... done
do ... end
  • Lua, Ruby (pass blocks as arguments, for loop), Seed7 (encloses loop bodies between do and end)
X ... end (e.g. if ... end):
  • Ruby (if, while, until, def, class, module statements), OCaml (for & while loops), MATLAB (if & switch conditionals, for & while loops, try clause, package, classdef, properties, methods, events, & function blocks), Lua (then / else & function)
(begin ...)
(progn ...)
(do ...)
Indentation
Others

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

Inline comments are generally those that use a newline character to indicate the end of a comment, and an arbitrary delimiter or sequence of tokens to indicate the beginning of a comment.

Examples:

Symbol Languages
C Fortran I to Fortran 77 (C in column 1)
REM BASIC, Batch files
:: Batch files, COMMAND.COM, cmd.exe
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, Make, Maple, Elixir, Julia, Nim
% TeX, Prolog, MATLAB, Erlang, S-Lang, Visual Prolog
// ActionScript, C (C99), C++, C#, D, F#, Go, Java, JavaScript, Kotlin, Object Pascal (Delphi), Objective-C, PHP, Rust, Scala, SASS, Swift, Xojo
' Monkey, Visual Basic, VBScript, Small Basic, Gambas, Xojo
! Fortran, Basic Plus, Inform, Pick Basic
; Assembly x86, AutoHotkey, AutoIt, Lisp, Common Lisp, Clojure, Rebol, Red, Scheme
-- Euphoria, Haskell, SQL, Ada, AppleScript, Eiffel, Lua, VHDL, SGML, PureScript, Elm
* Assembler S/360 (* in column 1), COBOL I to COBOL 85, PAW, Fortran IV to Fortran 77 (* in column 1), Pick Basic, GAMS (* in column 1)
|| Curl
" Vimscript, ABAP
\ Forth
*> COBOL 90

Block comments

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
comment ~ ; ALGOL 60, SIMULA
¢ ~ ¢,
# ~ #, co ~ co,
comment ~ comment
ALGOL 68
/* ~ */ ActionScript, AutoHotkey, C, C++, C#, D, Go, Java, JavaScript, kotlin, Objective-C, PHP, PL/I, Prolog, Rexx, Rust (can be nested), Scala (can be nested), SAS, SASS, SQL, Swift (can be nested), Visual Prolog, CSS
#cs ~ #ce AutoIt
/+ ~ +/ D (can be nested)
/# ~ #/ Cobra (can be nested)
<# ~ #> Powershell
<!-- ~ --> HTML, XML
=begin ~ =cut Perl
#`( ~ ) Raku (bracketing characters can be (), <>, {}, [], any Unicode characters with BiDi mirrorings, or Unicode characters with Ps/Pe/Pi/Pf properties)
=begin ~ =end Ruby
#<TAG> ~ #</TAG>, #stop ~ EOF,
#iffalse ~ #endif, #ifntrue ~ #endif,
#if false ~ #endif, #if !true ~ #endif
S-Lang
{- ~ -} Haskell (can be nested)
(* ~ *) Delphi, ML, Mathematica, Object Pascal, Pascal, Seed7, Applescript, OCaml (can be nested), Standard ML (can be nested), Maple, Newspeak, F#
{ ~ } Delphi, Object Pascal, Pascal, Red
{# ~ #} Nunjucks, Twig
{{! ~ }} Mustache, Handlebars
{{!-- ~ --}} Handlebars (cannot be nested, but may contain {{ and }})
|# ~ #| Curl
%{ ~ %} MATLAB (the symbols must be in a separate line)
#| ~ |# Lisp, Scheme, Racket (can be nested in all three).
#= ~ =# Julia
#[ ~ ]# Nim
--[[ ~ ]],
--[=[ ~ ]=],
--[=...=[ ~ ]=...=]
Lua (brackets can have any number of matching = characters; can be nested within non-matching delimiters)
" ~ " Smalltalk
(comment ~ ) Clojure

Unique variants

Fortran
  • Indenting lines in Fortran 66/77 is significant. The actual statement is in columns 7 through 72 of a line. Any non-space character in column 6 indicates that this line is a continuation of the previous line. A 'C' in column 1 indicates that this entire line is a comment. Columns 1 though 5 may contain a number which serves as a label. Columns 73 though 80 are ignored and may be used for comments; in the days of punched cards, these columns often contained a sequence number so that the deck of cards could be sorted into the correct order if someone accidentally dropped the cards. Fortran 90 removed the need for the indentation rule and added inline comments, using the ! character as the comment delimiter.
COBOL
  • In fixed format code, line indentation is significant. Columns 1–6 and columns from 73 onwards are ignored. If a * or / is in column 7, then that line is a comment. Until COBOL 2002, if a D or d was in column 7, it would define a "debugging line" which would be ignored unless the compiler was instructed to compile it.
Cobra
  • Cobra supports block comments with "/# ... #/" which is like the "/* ... */" often found in C-based languages, but with two differences. The # character is reused from the single-line comment form "# ...", and the block comments can be nested which is convenient for commenting out large blocks of code.
Curl
  • Curl supports block comments with user-defined tags as in |foo# ... #foo|.
Lua
  • Like raw strings, there can be any number of equals signs between the square brackets, provided both the opening and closing tags have a matching number of equals signs; this allows nesting as long as nested block comments/raw strings use a different number of equals signs than their enclosing comment: --[[comment --[=[ nested comment ]=] ]]. Lua discards the first newline (if present) that directly follows the opening tag.
Perl
  • Block comments in Perl are considered part of the documentation, and are given the name Plain Old Documentation (POD). Technically, Perl does not have a convention for including block comments in source code, but POD is routinely used as a workaround.
PHP
  • PHP supports standard C/C++ style comments, but supports Perl style as well.
Python
  • The use of the triple-quotes to comment-out lines of source, does not actually form a comment. The enclosed text becomes a string literal, which Python usually ignores (except when it is the first statement in the body of a module, class or function; see docstring).
Raku
  • Raku uses #`(...) to denote block comments. Raku actually allows the use of any "right" and "left" paired brackets after #` (i.e. #`(...), #`[...], #`{...}, #`<...>, and even the more complicated #`{{...}} are all valid block comments). Brackets are also allowed to be nested inside comments (i.e. #`{ a { b } c } goes to the last closing brace).
Ruby
  • Block comment in Ruby opens at =begin line and closes at =end line.
S-Lang
  • The region of lines enclosed by the #<tag> and #</tag> delimiters are ignored by the interpreter. The tag name can be any sequence of alphanumeric characters that may be used to indicate how the enclosed block is to be deciphered. For example, #<latex> could indicate the start of a block of LaTeX formatted documentation.
Scheme and Racket
  • The next complete syntactic component (s-expression) can be commented out with #; .
ABAP

ABAP supports two different kinds of comments. If the first character of a line, including indentation, is an asterisk (*) the whole line is considered as a comment, while a single double quote (") begins an in-line comment which acts until the end of the line. ABAP comments are not possible between the statements EXEC SQL and ENDEXEC because Native SQL has other usages for these characters. In the most SQL dialects the double dash (--) can be used instead.

Esoteric languages

Comment comparison

There is a wide variety of syntax styles for declaring comments in source code. BlockComment in italics is used here to indicate block comment style. InlineComment in italics is used here to indicate inline comment style.

Language In-line comment Block comment
Ada, Eiffel, Euphoria, Occam, SPARK, ANSI SQL, and VHDL -- InlineComment
ALGOL 60 comment BlockComment;
ALGOL 68 ¢ BlockComment ¢

comment BlockComment comment
co BlockComment co
# BlockComment #
£ BlockComment £

APL InlineComment
AppleScript -- InlineComment (* BlockComment *)
Assembly language (varies) ; InlineComment one example (most assembly languages use line comments only)
AutoHotkey ; InlineComment /* BlockComment */
AWK, Bash, Bourne shell, C shell, Maple, R, Tcl, and Windows PowerShell # InlineComment <# BlockComment #>
BASIC (various dialects): 'InlineComment (not all dialects)

*InlineComment (not all dialects)
!InlineComment (not all dialects)
REM InlineComment

C (K&R, ANSI/C89/C90), CHILL, PL/I, and REXX /* BlockComment */
C (C99), C++, Go, Swift and JavaScript // InlineComment /* BlockComment */
C# // InlineComment
/// InlineComment (XML documentation comment)
/* BlockComment */
/** BlockComment */ (XML documentation comment)
COBOL I to COBOL 85 * InlineComment (* in column 7)
COBOL 2002 *> InlineComment
Curl || InlineComment |# BlockComment #|

|foo# BlockComment #|

Cobra # InlineComment /# BlockComment #/ (nestable)
D // InlineComment
/// Documentation InlineComment (ddoc comments)
/* BlockComment */
/** Documentation BlockComment */ (ddoc comments)

/+ BlockComment +/ (nestable)
/++ Documentation BlockComment +/ (nestable, ddoc comments)

DCL $! InlineComment
ECMAScript (JavaScript, ActionScript, etc.) // InlineComment /* BlockComment */
Forth \ InlineComment ( BlockComment ) (single line as well as multiline)

( before -- after ) stack comment convention

FORTRAN I to FORTRAN 77 C InlineComment (C in column 1)
Fortran 90 ! InlineComment
Haskell -- InlineComment {- BlockComment -}
Java // InlineComment /* BlockComment */

/** BlockComment */ (Javadoc documentation comment)

Julia # InlineComment #= BlockComment =#
Lisp and Scheme ; InlineComment #| BlockComment |#
Lua -- InlineComment --[==[ BlockComment]==] (variable number of = signs)
Maple # InlineComment (* BlockComment *)
Mathematica (* BlockComment *)
Matlab % InlineComment %{
BlockComment (nestable)
%}

Note: Both percent–bracket symbols must be the only non-whitespace characters on their respective lines.
Nim # InlineComment #[ BlockComment ]#
Object Pascal // InlineComment (* BlockComment *)
{ BlockComment }
OCaml (* BlockComment (* nestable *) *)
Pascal, Modula-2, Modula-3, Oberon, and ML: (* BlockComment *)
Perl and Ruby # InlineComment =begin
BlockComment
=cut
(=end in Ruby) (POD documentation comment)

__END__
Comments after end of code

PHP # InlineComment
// InlineComment
/* BlockComment */
/** Documentation BlockComment */ (PHP Doc comments)
PILOT R:InlineComment
PLZ/SYS ! BlockComment !
PL/SQL and TSQL -- InlineComment /* BlockComment */
Prolog % InlineComment /* BlockComment */
Python # InlineComment ''' BlockComment '''
""" BlockComment """

(Documentation string when first line of module, class, method, or function)

R # InlineComment
Raku # InlineComment #`{
BlockComment
}

=comment
This comment paragraph goes until the next POD directive
or the first blank line.

Red ; InlineComment { BlockComment }
Rust // InlineComment

/// InlineComment ("Outer" rustdoc comment)
//! InlineComment ("Inner" rustdoc comment)

/* BlockComment */ (nestable)

/** BlockComment */ ("Outer" rustdoc comment)
/*! BlockComment */ ("Inner" rustdoc comment)

SAS * BlockComment;
/* BlockComment */
Seed7 # InlineComment (* BlockComment *)
Simula comment BlockComment;
! BlockComment;
Smalltalk "BlockComment"
Smarty {* BlockComment *}
Standard ML (* BlockComment *)
TeX, LaTeX, PostScript, Erlang, Elixir and S-Lang % InlineComment
Texinfo @c InlineComment

@comment InlineComment

TUTOR * InlineComment
command $$ InlineComment
Visual Basic ' InlineComment
Rem InlineComment
Visual Basic .NET ' InlineComment

''' InlineComment (XML documentation comment)
Rem InlineComment

Visual Prolog % InlineComment /* BlockComment */
Wolfram Language (* BlockComment *)
Xojo ' InlineComment
// InlineComment
rem InlineComment
  1. For multiple statements on one line
  2. Three different kinds of clauses, each separates phrases and the units differently:
      1. serial-clause using go-on-token (viz. semicolon): begin a; b; c end – units are executed in order.
      2. collateral-clause using and-also-token (viz. ","): begin a, b, c end – order of execution is to be optimised by the compiler.
      3. parallel-clause using and-also-token (viz. ","): par begin a, b, c end – units must be run in parallel threads.
  3. semicolon – result of receding statement hidden, comma – result displayed
  4. From the R Language Definition, section 3.2 Control structures: "A semicolon always indicates the end of a statement while a new line may indicate the end of a statement. If the current statement is not syntactically complete new lines are simply ignored by the evaluator."
  5. Bash Reference Manual, 3.1.2.1 Escape Character
  6. Python Documentation, 2. Lexical analysis: 2.1.5. Explicit line joining
  7. Mathworks.com Archived 7 February 2010 at the Wayback Machine
  8. https://ss64.com/nt/syntax-brackets.html
  9. "Scripts - Definition & Usage | AutoHotkey".
  10. For an M-file (MATLAB source) to be accessible by name, its parent directory must be in the search path (or current directory).
  11. "Nim Manual".
  12. "Mathworks.com". Archived from the original on 21 November 2013. Retrieved25 June 2013.
  13. "Algol68_revised_report-AB.pdf on PDF pp. 61–62, original document pp. 121–122"(PDF). Retrieved27 May 2014.
  14. "HTML Version of the Algol68 Revised Report AB". Archived from the original on 17 March 2013. Retrieved27 May 2014.
  15. "DLang.org, Lexical". Retrieved27 May 2014.
  16. "AutoItScript.com Keyword Reference, #comments-start". Retrieved27 May 2014.
  17. "slang-2.2.4/src/slprepr.c – line 43 to 113". Retrieved28 May 2014.
  18. "Punctuation · The Julia Language".
  19. "Nim Manual".
  20. "Python tip: You can use multi-line strings as multi-line comments", 11 September 2011, Guido van Rossum
  21. "Perl 6 Documentation (Syntax)". docs.perl6.org. Comments. Retrieved5 April 2017.
  22. "Perl 6 POD Comments".
  23. "Perl 6 POD (Abbreviated Blocks)".

Comparison of programming languages syntax Article Talk Language Watch Edit 160 160 Redirected from Statement terminator This comparison of programming languages compares the features of language syntax format for over 50 computer programming languages Contents 1 Expressions 2 Statements 2 1 Line continuation 3 Libraries 4 Blocks 5 Comments 5 1 Inline comments 5 2 Block comments 5 3 Unique variants 5 4 Comment comparison 6 See also 7 ReferencesExpressions EditProgramming language expressions can be broadly classified into four syntax structures prefix notationLisp 2 3 expt 4 5 infix notationFortran 2 3 4 5 suffix postfix or Reverse Polish notationForth 2 3 4 5 math like notationTUTOR 2 3 4 sup 5 sup note implicit multiply operatorStatements EditWhen the Programming Languages usually Algol descendants has statements they typically have conventions for statement separators statement terminators and line continuation A statement separator is used to demarcate boundaries between two separate statements A statement terminator is used to demarcate the end of an individual statement Languages that interpret the end of line to be the end of a statement are called line oriented languages Line continuation is a convention in line oriented languages where the newline character could potentially be misinterpreted as a statement terminator In such languages it allows a single statement to span more than just one line Language Statement separator terminator Secondary separator terminator 1 ABAP period separatedAda semicolon terminatedALGOL semicolon separatedALGOL 68 semicolon and comma separated 2 APL newline terminated Direct function separated SecondaryAppleScript newline terminatedAutoHotkey newline terminatedBASIC newline terminated colon separatedBoo newline terminatedC semicolon terminates statements comma separates expressionsC semicolon terminates statements comma separates expressionsC semicolon terminatedCOBOL whitespace separated sometimes period separated optionally separated with commas and semi colons Cobra newline terminatedCoffeeScript newline terminatedCSS semicolon separatedD semicolon terminatedEiffel newline terminated semicolonErlang colon separated period terminatedF newline terminated semicolonFortran newline terminated semicolonForth semicolons terminate word definitions space terminates word useGFA BASIC newline terminatedGo semicolon separated inserted by compiler Haskell in do notation newline separatedHaskell in do notation when braces are used semicolon separatedJava semicolon terminatedJavaScript semicolon separated but sometimes implicitly inserted on newlines Kotlin semicolon separated but sometimes implicitly inserted on newlines Lua whitespace separated semicolon optional Mathematica also called Wolfram semicolon separatedMATLAB newline terminated semicolon or comma 3 MUMPS also called M newline terminates line scope the closest to a statement that M has a space separates teminates a command allowing another command to follow Nim newline terminatedObject Pascal also Delphi semicolon separatedObjective C semicolon terminatedOCaml semicolon separatedPascal semicolon separatedPerl semicolon separatedPHP semicolon terminatedPick Basic newline terminated semicolon separatedPowerShell newline terminated semicolon separatedProlog comma separated conjunction semicolon separated disjunction period terminated clause Python newline terminated semicolonR newline terminated 4 semicolon 4 Raku semicolon separatedRed whitespace separatedRuby newline terminated semicolonRust semicolon terminates statements comma separates expressionsScala newline terminated semicolon optional semicolonSeed7 semicolon separated semicolon termination is allowed Simula semicolon separatedS Lang semicolon separatedSmalltalk period separatedStandard ML semicolon separatedSwift semicolon separated inserted by compiler Visual Basic newline terminated colon separatedVisual Basic NET newline terminated colon separatedWolfram Language semicolon separatedXojo newline terminatedLanguage Statement separator terminator Secondary separator terminator 1 Line continuation Edit Line continuation is generally done as part of lexical analysis a newline normally results in a token being added to the token stream unless line continuation is detected Whitespace Languages that do not need continuationsAda Lines terminate with semicolon C Lines terminate with semicolon JavaScript Lines terminate with semicolon which may be inferred Lua OCamlAmpersand as last character of lineFortran 90 Fortran 95 Fortran 2003 Fortran 2008Backslash as last character of linebash 5 and other Unix shells C and C preprocessor Mathematica and Wolfram Language Python 6 Ruby JavaScript only within single or double quoted stringsBacktick as last character of linePowerShellHyphen as last character of lineSQL PlusUnderscore as last character of lineAutoIt Cobra Visual Basic XojoEllipsis as three periods not one special character MATLAB The ellipsis token need not be the last characters on the line but any following it will be ignored 7 In essence it begins a comment that extends through i e including the first subsequent newline character Contrast this with an inline comment which extends until the first subsequent newline Comma delimiter as last character of lineRuby comment may follow delimiter Left bracket delimiter as last character of lineBatch file starting a parenthetical block can allow line continuation 8 Ruby left parenthesis left square bracket or left curly bracketOperator as last object of lineRuby comment may follow operator Operator as first character of continued lineAutoHotkey Any expression operators except and as well as a comma or a period 9 Backslash as first character of continued lineVimscriptSome form of inline comment serves as line continuationTurbo Assembler m4 dnl TeX Character positionFortran 77 A non comment line is a continuation of the previous non comment line if any non space character appears in column 6 Comment lines cannot be continued COBOL String constants may be continued by not ending the original string in a PICTURE clause with then inserting a in column 7 same position as the for comment is used TUTOR Lines starting with a tab after any indentation required by the context continue the previous command End and Begin using normal quotesC and C preprocessor The string is ended normally and continues by starting with a quote on the next line Libraries EditThis section needs expansion You can help by adding to it December 2009 To import a library is a way to read external possibly compiled routines programs or packages Imports can be classified by level module package class procedure and by syntax directive name attributes File importaddpath i directory i MATLAB 10 COPY filename COBOL include i filename i Prolog include file i filename i ASP include i filename i AutoHotkey AutoIt C C include lt i filename i gt AutoHotkey AutoIt C C import i filename i Objective C import lt i filename i gt Objective C Import filename Mathematica and Wolfram Language include filename Fortran include i filename i PHP include filename program Pick Basic include filename program Pick Basic include i filename i Rust load i filename i Ruby load filenameRed require i filename i Lua require i filename i Perl PHP require filename Ruby source filename RPackage import include i filename i C C path i filename i mod i altname i Rusti import i module i Objective C lt lt i name i Mathematica and Wolfram Language use module module Prolog from i module i import Python extern crate i libname i Rust extern crate i libname i as i altname i Rust mod i modname i Rust library i package i R IMPORT i module i Oberon import i altname i i package name i Go import i package module i D import i altname i i package module i D import i Module i Haskell import qualified i Module i as i M i Haskell import i package i Java MATLAB kotlin import i modname i JavaScript import i altname i from i modname i JavaScript import i package i Scala import i package i Scala import i module i Swift import i module i Python require i modname i Lua require gem Ruby use i module i Fortran 90 use i module i only i identifier i Fortran 90 use i Module i Perl use Module qw i import options i Perl use i Package i i Name i Cobra uses i unit i Pascal with i package i AdaClass importfrom i module i import i class i Python import i package i i class i Java MATLAB kotlin import i class i from i modname i JavaScript import i class i from i modname i JavaScript import i class i as i altname i from i modname i JavaScript import i package i i class i Scala import i package i i class1 i gt i alternativeName i i class2 i Scala import i package i Scala use i Namespace ClassName i PHP use i Namespace ClassName as AliasName i PHPProcedure function importfrom i module i import i function i Python import i package module i i symbol i D import i package module i i altsymbolname i i symbol i D import i Module i i function i Haskell import i function i from modname JavaScript import i function i from i modname i JavaScript import i function i as i altname i from i modname i JavaScript import i package i i function i MATLAB import i package i i class i i function i Scala import i package i i class i i function i gt i alternativeName i i otherFunction i Scala use Module symbol Perl use function i Namespace function name i PHP use i Namespace function name as function alias name i PHP use i module i i submodule i i symbol i Rust use i module i i submodule i i symbol1 i i symbol2 i Rust use i module i i submodule i i symbol i as i altname i Rust Constant importuse const i Namespace CONST NAME i PHP The above statements can also be classified by whether they are a syntactic convenience allowing things to be referred to by a shorter name but they can still be referred to by some fully qualified name without import or whether they are actually required to access the code without which it is impossible to access the code even with fully qualified names Syntactic convenienceimport i package i Java import i package i i class i Java open i module i OCamlRequired to access codeimport altname i package name i Go import i altname i from i modname i JavaScript import i module i PythonBlocks EditA block is a notation for a group of two or more statements expressions or other units of code that are related in such a way as to comprise a whole Braces a k a curly brackets Curly bracket programming languages C C Objective C Go Java JavaScript ECMAScript C D Perl PHP for amp loop loops or pass a block as argument R Rust Scala S Lang Swift Windows PowerShell Haskell in do notation AutoHotkeyParentheses OCaml Prolog Standard MLSquare brackets Smalltalk blocks are first class objects a k a closures begin endAda ALGOL Pascal Ruby for do while amp do until loops OCaml SCL Simula Erlang do endPL I REXXdo doneBash for amp while loops Visual Basic Fortran TUTOR with mandatory indenting of block body Visual Prologdo endLua Ruby pass blocks as arguments for loop Seed7 encloses loop bodies between do and end X end e g if end Ruby if while until def class module statements OCaml for amp while loops MATLAB if amp switch conditionals for amp while loops try clause package classdef properties methods events amp function blocks Lua then else amp function begin Scheme progn Lisp do ClojureIndentationOff side rule languages Cobra CoffeeScript F Haskell in do notation when braces are omitted occam Python Nim Free form languages most descendants from ALGOL including C Pascal and Perl Lisp languagesOthersAda Visual Basic Seed7 if end if APL If EndIf or If End Bash sh and ksh if fi do done case esac ALGOL 68 begin end if fi do od Lua Pascal Modula 2 Seed7 repeat until COBOL IF END IF PERFORM END PERFORM etc for statements for sentences Visual Basic Net If End If For Next Do Loop Small Basic If EndIf For EndFor While EndWhileComments EditComments 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 tokens to indicate the beginning of a comment Examples Symbol LanguagesC Fortran I to Fortran 77 C in column 1 REM BASIC Batch files Batch files COMMAND COM cmd exeNB 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 Make Maple Elixir Julia Nim 11 TeX Prolog MATLAB 12 Erlang S Lang Visual Prolog ActionScript C C99 C C D F Go Java JavaScript Kotlin Object Pascal Delphi Objective C PHP Rust Scala SASS Swift Xojo Monkey Visual Basic VBScript Small Basic Gambas Xojo Fortran Basic Plus Inform Pick Basic Assembly x86 AutoHotkey AutoIt Lisp Common Lisp Clojure Rebol Red Scheme Euphoria Haskell SQL Ada AppleScript Eiffel Lua VHDL SGML PureScript Elm Assembler S 360 in column 1 COBOL I to COBOL 85 PAW Fortran IV to Fortran 77 in column 1 Pick Basic GAMS in column 1 Curl Vimscript ABAP Forth gt COBOL 90Block 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 Languagescomment ALGOL 60 SIMULA co co comment comment ALGOL 68 13 14 ActionScript AutoHotkey C C C D 15 Go Java JavaScript kotlin Objective C PHP PL I Prolog Rexx Rust can be nested Scala can be nested SAS SASS SQL Swift can be nested Visual Prolog CSS cs ce AutoIt 16 D can be nested 15 Cobra can be nested lt gt Powershell lt gt HTML XML begin cut Perl Raku bracketing characters can be lt gt any Unicode characters with BiDi mirrorings or Unicode characters with Ps Pe Pi Pf properties begin end Ruby lt a href wiki Tag metadata title Tag metadata TAG a gt lt a href wiki Tag metadata title Tag metadata TAG a gt stop a href wiki End of file title End of file EOF a iffalse endif ifntrue endif if false endif if true endif S Lang 17 Haskell can be nested Delphi ML Mathematica Object Pascal Pascal Seed7 Applescript OCaml can be nested Standard ML can be nested Maple Newspeak F Delphi Object Pascal Pascal Red Nunjucks Twig Mustache Handlebars Handlebars cannot be nested but may contain and Curl MATLAB 12 the symbols must be in a separate line Lisp Scheme Racket can be nested in all three Julia 18 Nim 19 Lua brackets can have any number of matching characters can be nested within non matching delimiters Smalltalk comment ClojureUnique variants Edit FortranIndenting lines in Fortran 66 77 is significant The actual statement is in columns 7 through 72 of a line Any non space character in column 6 indicates that this line is a continuation of the previous line A C in column 1 indicates that this entire line is a comment Columns 1 though 5 may contain a number which serves as a label Columns 73 though 80 are ignored and may be used for comments in the days of punched cards these columns often contained a sequence number so that the deck of cards could be sorted into the correct order if someone accidentally dropped the cards Fortran 90 removed the need for the indentation rule and added inline comments using the character as the comment delimiter COBOLIn fixed format code line indentation is significant Columns 1 6 and columns from 73 onwards are ignored If a or is in column 7 then that line is a comment Until COBOL 2002 if a D or d was in column 7 it would define a debugging line which would be ignored unless the compiler was instructed to compile it CobraCobra supports block comments with which is like the often found in C based languages but with two differences The character is reused from the single line comment form and the block comments can be nested which is convenient for commenting out large blocks of code CurlCurl supports block comments with user defined tags as in foo foo LuaLike raw strings there can be any number of equals signs between the square brackets provided both the opening and closing tags have a matching number of equals signs this allows nesting as long as nested block comments raw strings use a different number of equals signs than their enclosing comment comment nested comment Lua discards the first newline if present that directly follows the opening tag PerlBlock comments in Perl are considered part of the documentation and are given the name Plain Old Documentation POD Technically Perl does not have a convention for including block comments in source code but POD is routinely used as a workaround PHPMain article PHP syntax and semantics PHP supports standard C C style comments but supports Perl style as well PythonThe use of the triple quotes to comment out lines of source does not actually form a comment 20 The enclosed text becomes a string literal which Python usually ignores except when it is the first statement in the body of a module class or function see docstring RakuRaku uses to denote block comments 21 Raku actually allows the use of any right and left paired brackets after i e lt gt and even the more complicated are all valid block comments Brackets are also allowed to be nested inside comments i e a b c goes to the last closing brace RubyBlock comment in Ruby opens at begin line and closes at end line S LangThe region of lines enclosed by the lt tag gt and lt tag gt delimiters are ignored by the interpreter The tag name can be any sequence of alphanumeric characters that may be used to indicate how the enclosed block is to be deciphered For example lt latex gt could indicate the start of a block of LaTeX formatted documentation Scheme and RacketThe next complete syntactic component s expression can be commented out with ABAP ABAP supports two different kinds of comments If the first character of a line including indentation is an asterisk the whole line is considered as a comment while a single double quote begins an in line comment which acts until the end of the line ABAP comments are not possible between the statements EXEC SQL and ENDEXEC because Native SQL has other usages for these characters In the most SQL dialects the double dash can be used instead Esoteric languagesMany esoteric programming languages follow the convention that any text not executed by the instruction pointer e g Befunge or otherwise assigned a meaning e g Brainfuck is considered a comment Comment comparison Edit There is a wide variety of syntax styles for declaring comments in source code i BlockComment i in italics is used here to indicate block comment style i InlineComment i in italics is used here to indicate inline comment style Language In line comment Block commentAda Eiffel Euphoria Occam SPARK ANSI SQL and VHDL i InlineComment i ALGOL 60 comment i BlockComment i ALGOL 68 i BlockComment i u comment u i BlockComment i u comment u u co u i BlockComment i u co u i BlockComment i i BlockComment i APL i InlineComment i AppleScript i InlineComment i i BlockComment i Assembly language varies i InlineComment i one example most assembly languages use line comments only AutoHotkey i InlineComment i i BlockComment i AWK Bash Bourne shell C shell Maple R Tcl and Windows PowerShell i InlineComment i lt i BlockComment i gt BASIC various dialects i InlineComment i not all dialects i InlineComment i not all dialects i InlineComment i not all dialects REM i InlineComment i C K amp R ANSI C89 C90 CHILL PL I and REXX i BlockComment i C C99 C Go Swift and JavaScript i InlineComment i i BlockComment i C i InlineComment i i InlineComment i XML documentation comment i BlockComment i i BlockComment i XML documentation comment COBOL I to COBOL 85 i InlineComment i in column 7 COBOL 2002 gt i InlineComment i Curl i InlineComment i i BlockComment i foo i BlockComment i Cobra i InlineComment i i BlockComment i nestable D i InlineComment i Documentation i InlineComment i ddoc comments i BlockComment i Documentation i BlockComment i ddoc comments i BlockComment i nestable Documentation i BlockComment i nestable ddoc comments DCL i InlineComment i ECMAScript JavaScript ActionScript etc i InlineComment i i BlockComment i Forth i InlineComment i i BlockComment i single line as well as multiline i before i i after i stack comment conventionFORTRAN I to FORTRAN 77 C i InlineComment i C in column 1 Fortran 90 i InlineComment i Haskell i InlineComment i i BlockComment i Java i InlineComment i i BlockComment i i BlockComment i Javadoc documentation comment Julia i InlineComment i i BlockComment i Lisp and Scheme i InlineComment i i BlockComment i Lua i InlineComment i i BlockComment i variable number of signs Maple i InlineComment i i BlockComment i Mathematica i BlockComment i Matlab i InlineComment i br i BlockComment nestable i br Note Both percent bracket symbols must be the only non whitespace characters on their respective lines Nim i InlineComment i i BlockComment i Object Pascal i InlineComment i i BlockComment i i BlockComment i OCaml i BlockComment nestable i Pascal Modula 2 Modula 3 Oberon and ML i BlockComment i Perl and Ruby i InlineComment i begin br i BlockComment i br cut end in Ruby POD documentation comment END br i Comments after end of code i PHP i InlineComment i i InlineComment i i BlockComment i Documentation i BlockComment i PHP Doc comments PILOT R i InlineComment i PLZ SYS i BlockComment i PL SQL and TSQL i InlineComment i i BlockComment i Prolog i InlineComment i i BlockComment i Python i InlineComment i i BlockComment i br i BlockComment i Documentation string when first line of module class method or function R i InlineComment i Raku i InlineComment i br i BlockComment i br comment br i This comment paragraph goes until the next POD directive i br i or the first blank line i 22 23 Red i InlineComment i i BlockComment i Rust i InlineComment i i InlineComment i Outer rustdoc comment i InlineComment i Inner rustdoc comment i BlockComment i nestable i BlockComment i Outer rustdoc comment i BlockComment i Inner rustdoc comment SAS i BlockComment i i BlockComment i Seed7 i InlineComment i i BlockComment i Simula comment i BlockComment i i BlockComment i Smalltalk i BlockComment i Smarty i BlockComment i Standard ML i BlockComment i TeX LaTeX PostScript Erlang Elixir and S Lang i InlineComment i Texinfo c i InlineComment i comment i InlineComment i TUTOR i InlineComment i i command i i InlineComment i Visual Basic i InlineComment i Rem i InlineComment i Visual Basic NET i InlineComment i i InlineComment i XML documentation comment Rem i InlineComment i Visual Prolog i InlineComment i i BlockComment i Wolfram Language i BlockComment i Xojo i InlineComment i i InlineComment i rem i InlineComment i See also EditC syntax C syntax Curly bracket programming languages a broad family of programming language syntaxes Java syntax JavaScript syntax PHP syntax and semantics Python syntax and semanticsReferences Edit a b For multiple statements on one line Three different kinds of clauses each separates phrases and the units differently serial clause using go on token viz semicolon begin a b c end units are executed in order collateral clause using and also token viz begin a b c end order of execution is to be optimised by the compiler parallel clause using and also token viz par begin a b c end units must be run in parallel threads semicolon result of receding statement hidden comma result displayed a b From the R Language Definition section 3 2 Control structures A semicolon always indicates the end of a statement while a new line may indicate the end of a statement If the current statement is not syntactically complete new lines are simply ignored by the evaluator Bash Reference Manual 3 1 2 1 Escape Character Python Documentation 2 Lexical analysis 2 1 5 Explicit line joining Mathworks com Archived 7 February 2010 at the Wayback Machine https ss64 com nt syntax brackets html Scripts Definition amp Usage AutoHotkey For an M file MATLAB source to be accessible by name its parent directory must be in the search path or current directory Nim Manual a b Mathworks com Archived from the original on 21 November 2013 Retrieved 25 June 2013 Algol68 revised report AB pdf on PDF pp 61 62 original document pp 121 122 PDF Retrieved 27 May 2014 HTML Version of the Algol68 Revised Report AB Archived from the original on 17 March 2013 Retrieved 27 May 2014 a b DLang org Lexical Retrieved 27 May 2014 AutoItScript com Keyword Reference comments start Retrieved 27 May 2014 slang 2 2 4 src slprepr c line 43 to 113 Retrieved 28 May 2014 Punctuation The Julia Language Nim Manual Python tip You can use multi line strings as multi line comments 11 September 2011 Guido van Rossum Perl 6 Documentation Syntax docs perl6 org Comments Retrieved 5 April 2017 Perl 6 POD Comments Perl 6 POD Abbreviated Blocks Retrieved from https en wikipedia org w index php title Comparison of programming languages syntax amp oldid 1062502617 Statements, wikipedia, wiki, book,

books

, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.