What is the difference between “keyword” and “reserved word”?

前端 未结 10 2489
再見小時候
再見小時候 2020-12-13 05:54

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

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 06:25

    keyword, - a word with special meaning in a particular context. It's semantic definition.

    reserved word is a word that cannot be used as an identifier - such as, variable, and function name. It's syntactic definition.

    E.g.In Java, all keywords are reserved words. Probably not the reverse. goto is reserved word but not used and has no function.

    In older languages like FORTRAN there were keywords but no reserved words.

    However, keyword and reserved word are used interchangeably.

提交回复
热议问题