What's the difference between a keyword and a reserved word?
For example, in the proposal for concepts in C++ one can read the following statement:
This proposal introduces five new keywords: concept, concept map, where, axiom, and late check. All of these keywords will also be reserved words.
Keywords are predefined which have a unique meaning and functionality in Java programming language. These keywords are also known as reserved keywords which mean they cannot be used as a variable name, class, method or any other identifier.
Often found in programming languages and macros, reserved words are terms or phrases appropriated for special use that may not be utilized in the creation of variable names. For example, "print" is a reserved word because it is a function in many languages to show text on the screen.
Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier. For example: int money; Here, int is a keyword that indicates money is a variable of type int (integer).
a word in a programming language or computer system that has a fixed meaning and therefore cannot be redefined by a programmer.
Keywords have a special meaning in a language, and are part of the syntax.
Reserved words are words that cannot be used as identifiers (variables, functions, etc.), because they are reserved by the language.
In practice most keywords are reserved words and vice versa. But because they're two different things it may happen that a keyword is not a reserved word (e.g. a keyword only has meaning in a special context, and can therefore be used as an identifier), or a reserved word is not a keyword (e.g. because it is reserved for future use).
Update: Some examples as given by others that illustrate the distinction:
goto
is a reserved word but not a keyword (as a consequence, you cannot use it at all)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With