Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Semicolon
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Computing == {{See also|Colon (punctuation)#Computing}} === Programming === In [[computer programming]], the semicolon is often used to separate multiple [[Statement (programming)|statements]] (for example, in [[Perl]],<ref name='perl'>{{cite web |url=https://perldoc.perl.org/perlsyn#Simple-Statements |title=perlsyn - Perl syntax |type=subtitle: Simple Statements |website=Perldoc Browser |date=28 May 2022 |archive-date=12 November 2022 |archive-url=https://web.archive.org/web/20221112015442/https://perldoc.perl.org/perlsyn#Simple-Statements |url-status=live}}</ref> [[Pascal (programming language)|Pascal]],<ref name='pascal'>{{cite web |url=https://wiki.freepascal.org/; |website=Free Pascal and Lazarus Wiki |date=4 July 2021 |archive-date=22 October 2021 |archive-url=https://web.archive.org/web/20211022160946/https://wiki.freepascal.org/; |url-status=live|title=Free Pascal wiki }}</ref> and [[SQL]];<ref name='sql'>{{cite web |url=https://www.postgresql.org/docs/current/sql-syntax-lexical.html |title=Documentation: 15: 4.1. Lexical Structure |website=PostgreSQL |access-date=28 November 2022 |archive-date=21 October 2022 |archive-url=https://web.archive.org/web/20221021073901/https://www.postgresql.org/docs/current/sql-syntax-lexical.html |url-status=live}}</ref> see [[Pascal (programming language)#Semicolons as statement separators|Pascal: Semicolons as statement separators]]). In other languages, semicolons are called ''terminator''s<ref name="c-sharp-introduction">{{cite web | access-date = 2011-07-29 | first = H. | last = Mössenböck | location = [[Linz, Austria|Linz]] | page = 34 | publisher = University of Linz | title = Introduction to C# – The new language for Microsoft .NET | type = subtitle: Statements | quote = Empty statement: ; // ; is a ''terminator'', not a ''separator'' | url = http://ssw.jku.at/Teaching/Lectures/CSharp/Tutorial/Part1.pdf | archive-date = 2011-09-29 | archive-url = https://web.archive.org/web/20110929062908/http://ssw.jku.at/Teaching/Lectures/CSharp/Tutorial/Part1.pdf | url-status = live }}.</ref> and are required after every statement (such as in [[PL/I]],<ref>{{cite book | access-date = 2021-01-04 | page = 14 | publisher = IBM | title = IBM System/360 Operating System PL/I Language Specifications | quote = A statement, which is a string of characters, is always terminated by the special character, semicolon. | id = C28-6571-3 | url = http://bitsavers.org/pdf/ibm/360/pli/C28-6571-3_PL_I_Language_Specifications_Jul66.pdf | date = July 1966 | archive-date = 2021-11-09 | archive-url = https://web.archive.org/web/20211109194134/http://bitsavers.org/pdf/ibm/360/pli/C28-6571-3_PL_I_Language_Specifications_Jul66.pdf | url-status = live }}</ref> [[Java (programming language)|Java]],<ref name='java'>{{cite web |url=https://docs.oracle.com/javase/specs/jls/se18/html/jls-14.html |title=The Java® Language Specification - Chapter 14. Blocks, Statements, and Patterns |website=Oracle Help Center |date=23 February 2022 |publisher=Oracle |archive-date=8 June 2022 |archive-url=https://web.archive.org/web/20220608143908/https://docs.oracle.com/javase/specs/jls/se18/html/jls-14.html |url-status=live}}</ref> and the [[C (programming language)|C]]<ref name='c99'>{{cite web |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf |title=ISO/IEC 9899:TC3 — Programming languages — C |date=7 September 2007 |author=ISO/IEC JTC1/SC22/WG14 |archive-date=16 April 2020 |archive-url=https://archive.today/20200416164053/http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf |url-status=live |page=132}}</ref> family). Today semicolons as terminators has largely won out, but this was a divisive issue in programming languages from the 1960s into the 1980s.<ref>{{cite book | title = Object-Oriented Software Construction | first = Bertrand | last = Meyer | author-link = Bertrand Meyer | page = [https://books.google.com/books?ei=7eZ7VKGWM4friQK6xICIAg&id=xls_AQAAIAAJ&dq=semicolon 897] | edition = Second | year = 1997 | isbn = 978-0-13-629155-8 | title-link = Object-Oriented Software Construction }}</ref> An influential and frequently cited study in this debate was {{harvtxt|Gannon|Horning|1975}}, 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."<ref>{{cite book | title = Software Metrics: An Analysis and Evaluation | first1 = Alan J | last1 = Perlis | first2 = Frederick | last2 = Sayward | first3 = Mary | last3 = Shaw | page = [https://books.google.com/books?id=9dNw2_RYNLYC&q=semicolon 324] | year = 1981 | isbn = 978-0-26-216083-4 | publisher = MIT Press }}</ref> The study has been criticized as flawed by proponents of semicolon as a separator,<ref name="plde">{{cite tech report | title = Principles of language design and evolution | url = http://se.ethz.ch/~meyer/publications/hoare/evolution.pdf | first = Bertrand | last = Meyer | author-link = Bertrand Meyer | url-status = live | archive-url = https://web.archive.org/web/20120109190541/http://se.ethz.ch/~meyer/publications/hoare/evolution.pdf | archive-date = 9 January 2012 }}</ref> 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]],<ref name='bpcl'>{{cite web |url=https://www.bell-labs.com/usr/dmr/www/bcpl.pdf |title=The BCPL Reference Manual |date=21 July 1967 |website=Dennis M Ritchie's personal page |first=Martin |last=Richards |archive-date=11 June 2015 |archive-url=https://web.archive.org/web/20150611114538/https://www.bell-labs.com/usr/dmr/www/bcpl.pdf |url-status=live}}</ref> [[Python (programming language)|Python]],<ref name='python'>{{cite web |url=https://docs.python.org/3/reference/simple_stmts.html |title=The Python Language Reference - 7. Simple statements |date=22 January 2016 |publisher=Python Software Foundation |archive-date=7 October 2017 |archive-url=https://archive.today/20171007042643/https://docs.python.org/3/reference/simple_stmts.html |url-status=live}}</ref> [[R (programming language)|R]],<ref name='r'>{{cite web |url=https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Control-structures |title=R Language Definition |type=subtitle: 3.2 Control structures |website=The Comprehensive R Archive Network |date=31 October 2022 |archive-date=21 November 2022 |archive-url=https://web.archive.org/web/20221121131338/https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Control-structures |url-status=live}}</ref> [[Eiffel (programming language)|Eiffel]],<ref name='eiffel'>{{cite web |url=http://www.gobosoft.com/eiffel/syntax/ |title=Eiffel: The Syntax |date=2 September 2019 |website=Gobo Eiffel Project |archive-date=8 August 2022 |archive-url=https://web.archive.org/web/20220808043456/http://gobosoft.com/eiffel/syntax/ |url-status=live}}</ref> and [[Go (programming language)|Go]],<ref name='go'>{{cite web |url=https://go.dev/ref/spec#Tokens |title=The Go Programming Language Specification |type=subtitle: Tokens |website=The Go Programming Language |date=29 June 2022 |archive-date=27 November 2022 |archive-url=https://web.archive.org/web/20221127233150/https://go.dev/ref/spec#Tokens |url-status=live}}</ref> 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.<ref name="plde" /> The use of semicolons in control-flow structures and blocks of code is varied – semicolons are generally omitted after a closing brace, but included for a single statement branch of a control structure (the "then" clause), except in Pascal, where a semicolon terminates the entire if...then...else clause (to avoid [[dangling else]]) and thus is not allowed between a "then" and the corresponding "else", as this causes unnesting. This use originates with [[ALGOL 60]]<ref name='algol'>{{cite web |url=https://www.masswerk.at/algol60/report.htm#4 |title=Revised Report on the Algorithmic Language Algol 60 |type=subtitle: 4. Statements |date=1 January 1963 |website=mass:werk |archive-date=25 June 2007 |archive-url=https://archive.today/20070625171638/http://www.masswerk.at/algol60/report.htm |url-status=live}}</ref> and falls between the comma {{char|,}}{{snd}} used as a list separator{{snd}} and the period/full stop {{char|.}}{{snd}} 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 (programming language)|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.<ref>{{cite web |url=http://damienkatz.net/2008/03/what_sucks_abou.html |title=What Sucks About Erlang |last=Katz |first=Damien |date=9 March 2008 |archive-date=14 June 2013 |archive-url=https://archive.today/20130614160612/http://damienkatz.net/2008/03/what_sucks_abou.html |url-status=dead}}</ref> 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 (code)|NOP]] (no operation or null command); compare [[trailing comma]]s 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 (programming language)|APL]] uses semicolons to separate declarations of local variables<ref name="apl">{{cite web |url=http://docs.dyalog.com/13.0/Dyalog%20APL%20Language%20Reference.v13.0.pdf |title=Dyalog APL Language Reference Manual | access-date=14 February 2012 |date=April 2011 |publisher=Dyalog Limited |archive-date=4 March 2016 |archive-url=https://web.archive.org/web/20160304040415/http://docs.dyalog.com/13.0/Dyalog%20APL%20Language%20Reference.v13.0.pdf |url-status=live}}</ref>{{Rp|p=61}} and to separate axes when indexing multidimensional arrays, for example, <code>matrix[2;3]</code>.<ref name="apl"/>{{Rp|pp=220,275}} Other languages (for instance, some [[assembly language]]s<ref name='nasm'>{{cite web |url=https://www.nasm.us/xdoc/2.15.05/html/nasmdoc3.html |title=Chapter 3: The NASM Language |date=28 August 2020 |website=NASM - The Netwide Assembler |archive-date=25 October 2022 |archive-url=https://web.archive.org/web/20221025180850/https://www.nasm.us/xdoc/2.15.05/html/nasmdoc3.html |url-status=live}}</ref> and [[Lisp (programming language)|LISP]]<ref name='common-lisp'>{{cite web |url=http://www.lispworks.com/documentation/HyperSpec/Body/02_dd.htm |title=Common Lisp HyperSpec |type=subtitle: Section 2.4.4 |publisher=LispWorks |archive-date=18 June 2013 |archive-url=https://archive.today/20130618201107/http://www.lispworks.com/documentation/HyperSpec/Body/02_dd.htm |url-status=live}}</ref> dialects, [[; (CONFIG.SYS directive)|CONFIG.SYS]] and [[INI file#Comments|INI file]]s) use semicolons to mark the beginning of [[comment (computer programming)|comments]]. Example [[C (programming language)|C]] code: <syntaxhighlight lang="C"> int main() { int x, y; x = 1; y = 2; printf("X + Y = %d", x + y); return 0; } </syntaxhighlight> Or in [[JavaScript]]: <syntaxhighlight lang="JavaScript"> var x = 1; var y = 2; alert("X + Y = " + (x + y)); </syntaxhighlight> Conventionally, in many languages, each statement is written on a separate line, but this is not typically a requirement of the language. In the above examples, two statements are placed on the same line; this is legal, because the semicolon separates the two statements. Thus programming languages like Java, the C family, Javascript etc. use semicolons to obtain a proper structure in the respective languages. === Data === <!--- Use common sense – example lists should not be comprehensive and adding your pet language undermines the quality of the article ---> 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 [[Delimiter|delimited]] by a semicolon. In [[Microsoft Excel]], the semicolon is used as a list separator, especially in cases where the decimal separator is a comma, such as <code> 0,32; 3,14; 4,50</code>, instead of <code>0.32, 3.14, 4.50</code>. In [[Lua (programming language)|Lua]],<ref name='lua'>{{cite web |url=https://www.lua.org/manual/5.4/manual.html#3.4.9 |title=Lua 5.4 Reference Manual |at=3.4.9 – Table Constructors |date=13 January 2022 |archive-date=1 October 2022 |archive-url=https://archive.today/20221001132750/https://www.lua.org/manual/5.4/manual.html |url-status=live}}</ref> semicolons or commas can be used to separate table elements. In [[MATLAB]] and [[GNU Octave]],<ref name='octave'>{{cite web |url=https://docs.octave.org/interpreter/Simple-Examples.html#Creating-a-Matrix |title=GNU Octave (version 7.3.0) |at=1.2.2 Creating a Matrix |date=2 November 2022 |archive-date=28 November 2022 |archive-url=https://web.archive.org/web/20221128221701/https://docs.octave.org/interpreter/Simple-Examples.html#Creating-a-Matrix |url-status=live |publisher=GNU Octave |access-date=28 November 2022 }}</ref> 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.<ref name='mdn'>{{cite web |url=https://developer.mozilla.org/en-US/docs/Glossary/Entity |title=Entity |date=21 September 2022 |website=[[MDN Web Docs|MDN]] |archive-date=25 November 2022 |archive-url=https://web.archive.org/web/20221125232110/https://developer.mozilla.org/en-US/docs/Glossary/Entity |url-status=live}}</ref> The declarations of a style attribute in [[Cascading Style Sheets]] (CSS) are separated and terminated with semicolons.<ref>{{cite web |url=https://www.w3schools.com/css/css_syntax.asp |title=CSS Syntax |website=[[W3Schools]] |archive-date=25 February 2021 |archive-url=https://archive.today/20210225234210/https://www.w3schools.com/css/css_syntax.asp |url-status=live}}</ref> The file system of [[RSX-11]] and [[OpenVMS]], [[Files-11]], uses semicolons to indicate a [[Versioning file system|file's version number]].<ref>{{cite web |url=http://www.alticore.eu/cgi-bin/conan?key=Ext_File_Specs~Using~File_Specification_Differences&explode=yes&title=VMS%20Help |title=Ext File Specs, Using File Specification Differences |website=VMS Help |publisher=[[Consiglio Nazionale delle Ricerche]] |archive-date=7 August 2020 |archive-url=https://web.archive.org/web/20200807022056/http://www.alticore.eu/cgi-bin/conan?key=Ext_File_Specs~Using~File_Specification_Differences&explode=yes&title=VMS%20Help |url-status=dead}}</ref> The semicolon is permitted in [[long filename]]s in the [[Microsoft Windows]] file systems [[NTFS]] and [[VFAT]], but not in its [[8.3 filename|short names]].<ref>{{cite web |url=https://docs.microsoft.com/en-us/windows/win32/msi/filename |title=Filename - Win32 Apps |website=Microsoft Learn |publisher=Microsoft |archive-date=28 August 2019 |archive-url=https://web.archive.org/web/20190828072842/https://docs.microsoft.com/en-us/windows/win32/msi/filename |url-status=live |date=31 May 2018}}</ref> In some [[delimiter-separated values]] file formats, the semicolon is used as the separator character, as an alternative to [[comma-separated values]].
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Semicolon
(section)
Add topic