Difference between reserved words and predefined identifiers
Answers
Answered by
1
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:
In Java, goto is a reserved word but not a keyword (as a consequence, you cannot use it at all)
Fortran has no reserved words, all keywords (if, then, etc.) can be used as identifiers
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:
In Java, goto is a reserved word but not a keyword (as a consequence, you cannot use it at all)
Fortran has no reserved words, all keywords (if, then, etc.) can be used as identifiers
Similar questions