“关键字"与“关键字"之间有什么区别和“保留字"? [英] What is the difference between "keyword" and "reserved word"?

查看:139
本文介绍了“关键字"与“关键字"之间有什么区别和“保留字"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关键字保留字有什么区别?

例如,在建议书中在C ++中可以读取以下语句:

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 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:

  • 在Java中,goto是保留字,但不是关键字(因此,您完全不能使用它)
  • Fortran没有没有保留字,所有关键字(如果有,那么等等)都可以用作标识符
  • 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

这篇关于“关键字"与“关键字"之间有什么区别和“保留字"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆