Difference between revisions of "Reserved word"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Created page with "In a programming language, a '''reserved word''' (also known as a '''reserved identifier''') is a word that cannot be used as an identifier, such as the name of a variable...")
 
(Description)
Line 3: Line 3:
 
== Description ==
 
== Description ==
  
This is a [[Syntax (programming language|syntactic definition]], and a reserved word may have no [[meaning]].
+
This is a [[Syntax (programming languages)|syntactic definition]], and a reserved word may have no [[meaning]].
  
 
== Keyword ==
 
== Keyword ==

Revision as of 10:30, 3 September 2015

In a programming language, a reserved word (also known as a reserved identifier) is a word that cannot be used as an identifier, such as the name of a variable, function, or label -- it is "reserved from use".

Description

This is a syntactic definition, and a reserved word may have no meaning.

Keyword

A closely related and often conflated notion is a keyword which is a word with special meaning in a particular context. This is a semantic definition. By contrast, names in a standard library but not built into the language are not considered reserved words or keywords. The terms "reserved word" and "keyword" are often used interchangeably – one may say that a reserved word is "reserved for use as a keyword" – and formal use varies from language to language; for this article we distinguish as above.

In general reserved words and keywords need not coincide, but in most modern languages keywords are a subset of reserved words, as this makes parsing easier, since keywords cannot be confused with identifiers. In some languages, like C or Python, reserved words and keywords coincide, while in other languages, like Java, all keywords are reserved words, but some reserved words are not keywords – these are "reserved for future use". In yet other languages, such as ALGOL and PL/I there are keywords but no reserved words, with keywords being distinguished from identifiers by other means.

See also =

External links