What does ::=
mean in programming documentation?
For example in the Lua documentation: or in Python documentation.

- 3,967
- 6
- 30
- 35
4 Answers
It symbolizes 'symbol derivation rule' in Backus–Naur Form
Meaning that in:
<symbol> ::= __expression__
nonterminal <symbol>
consists of (is defined as, is constructed from, derives from) __expression__
It's used to describe language grammars.
Notice that both examples are in Extended Backus–Naur Form, but using a traditional BNF symbol-expression separator (::=
).

- 36,297
- 6
- 91
- 90
-
Is there any difference between
used in your answer and "identifier" used in m0skit0's answer? It looks like both are names i.e. ways of identifying or referring to data. – Charles Holbrow Feb 08 '12 at 15:29 -
1@AudiOishi no, the `<` and `>` are used only to mark the difference between terminals and nonterminals. It's normal to omit them in EBNF, as terminals are quoted. In BNF terminals didn't have to be quoted so there had to be some way to differentiate them from non-terminals. – soulcheck Feb 08 '12 at 15:33
-
We also sometimes see a single colon followed by an equals sign (e.g. http://www.ietf.org/rfc/rfc1806.txt). Is that the same meaning? – Shaun Luttin Oct 27 '15 at 15:33
-
1@ShaunLuttin yes, though it might create confusion with assignment operator. – soulcheck Oct 27 '15 at 15:39
This is Backus-Naur Form (BNF) notation describing the language. ::=
in this context means is defined as.
For example, in the Python language documentation you refer to, an identifier is defined as a letter or an underscore, followed by a letter, a digit or an underscore. The notation then goes on to describe what a letter and a digit is defined as, and so on.

- 46,145
- 13
- 104
- 123

- 1,269
- 13
- 14
-
1Is there an explanation for why `::=` means "is defined as"? Like the way symbols like `+=` and `<>` make sense? – Kyle Delaney Nov 19 '16 at 00:51
As others have already said, it's part of the BNF notation. Wikipedia has an explanation and some examples, which I won't repeat here.
The history and evolution of the ::=
symbol itself is explained in The History of the ALGOL Effort (p29 onwards).

- 486,780
- 108
- 951
- 1,012
The given element syntax. For example:
identifier ::= (letter|"_") (letter | digit | "_")*
Means all identifiers must conform to the given syntax rule.

- 25,268
- 11
- 79
- 127