Programming In
computer programming, the semicolon is often used to separate multiple
statements (for example, in
Perl,
Pascal, and
SQL; see
Pascal: Semicolons as statement separators). In other languages, semicolons are called
terminators and are required after every statement (such as in
PL/I,
Java, and the
C family). Today semicolons as terminators has largely won out, but this was a divisive issue in programming languages from the 1960s into the 1980s. An influential and frequently cited study in this debate was , which concluded strongly in favor of semicolon as a terminator: "The most important [result] was that having a semicolon as a statement terminator was better than having a semicolon as a statement separator." The study has been criticized as flawed by proponents of semicolon as a separator, due to participants being familiar with a semicolon-as-terminator language and unrealistically strict grammar. Nevertheless, the debate ended in favor of semicolon as terminator. Therefore, semicolon provides structure to the programming language. Semicolons are optional in a number of languages, including
BCPL,
Python,
R,
Eiffel, and
Go, meaning that they are part of the
formal grammar for the language but can be inferred in many or all contexts (e.g., by end of line that ends a statement, as in Go and R). As languages can be designed without them, semicolons are considered an unnecessary nuisance by some. and falls between the comma used as a list separatorand the period/full stop used to mark the end of the program. The semicolon, as a mark separating statements, corresponds to the ordinary English usage of separating independent clauses and gives the entire program the gross syntax of a single ordinary sentence. Of these other characters, whereas commas have continued to be widely used in programming for lists (and rare other uses, such as the
comma operator that separates expressions in C), they are rarely used otherwise, and the period as the end of the program has fallen out of use. The last major use of the comma, semicolon, and period hierarchy is in
Erlang (1986), where commas separate expressions; semicolons separate clauses, both for control flow and for function clauses; and periods terminate statements, such as function definitions or module attributes, not the entire program. Drawbacks of having multiple different separators or terminators (compared to a single terminator and single grouping, as in semicolon-and-braces) include mental overhead in selecting punctuation, and overhead in rearranging code, as this requires not only moving lines around, but also updating the punctuation. In some cases the distinction between a separator and a terminator is strong, such as early versions of Pascal, where a final semicolon yields a
syntax error. In other cases a final semicolon is treated either as optional syntax or as being followed by a null statement, which is either ignored or treated as a
NOP (no operation or null command); compare
trailing commas in lists. In some cases a blank statement is allowed, allowing a sequence of semicolons or the use of a semicolon by itself as the body of a control-flow structure. For example, a blank statement (a semicolon by itself) stands for a NOP in C/C++, which is useful in
busy waiting synchronization loops.
APL uses semicolons to separate declarations of local variables and to separate axes when indexing multidimensional arrays, for example, matrix[2;3]. and
LISP dialects,
CONFIG.SYS and
INI files) use semicolons to mark the beginning of
comments.
Data The semicolon is often used to separate elements of a string of text. For example, multiple e-mail addresses in the "To" field in some e-mail clients have to be
delimited by a semicolon. In
Microsoft Excel and other
spreadsheet applications, the semicolon is used as a list separator, especially in cases where the
decimal separator is a comma, such as 0,32; 3,14; 4,50, instead of 0.32, 3.14, 4.50. It is also used as an
function argument separator, when localization using comma as the decimal separator is used; for example: =SUMA(A1;D2) in the
Czech localization of Excel is equivalent of =SUM(A1:D2) in the
English-language localizations. In
Lua, semicolons or commas can be used to separate table elements. In
MATLAB and
GNU Octave, the semicolon can be used as a row separator when defining a vector or matrix (whereas a comma separates the columns within a row of a vector or matrix) or to execute a command silently, without displaying the resulting output value in the console. In
HTML, a semicolon is used to terminate a
character entity reference, either named or numeric. The declarations of a style attribute in
Cascading Style Sheets (CSS) are separated and terminated with semicolons. The file system of
RSX-11 and
OpenVMS,
Files-11, uses semicolons to indicate a
file's version number. The semicolon is permitted in
long filenames in the
Microsoft Windows file systems
NTFS and
VFAT, but not in its
short names. In some
delimiter-separated values file formats, the semicolon is used as the separator character, as an alternative to
comma-separated values. == Mathematics ==