声明和状态

发布于 2024-09-02 03:26:05 字数 86 浏览 5 评论 0原文

“声明”一词以“国家”一词开头,这是否有更深层的含义,或者这只是一个奇怪的巧合?请注意,英语不是我的母语,所以答案对你来说可能是显而易见的,但对我来说不是;)

Is there any deeper meaning in the fact that the word "statement" starts with the word "state", or is that just a curious coincidence? Note that english is not my native language, so the answer might be obvious to you, but not me ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

独﹏钓一江月 2024-09-09 03:26:05

英语单词“statement”确实源自动词形式“state”,但编程术语“state”和“statement”彼此之间没有任何有意义的联系。编程语言中的语句仅仅是语法结构,并不意味着涉及任何状态。

The English word "statement" does derive from the verb form of "state", but the programming terms "state" and "statement" aren't related to each other in any meaningful way. A statement in a programming language is merely a syntactic construct and does not imply that any state is involved.

深陷 2024-09-09 03:26:05

正如克里斯托弗所指出的,从词源学上来说,答案是肯定的。

然而,我认为在编程中也存在联系。语句(与表达式相反,表达式是可以评估其值的语法元素)是表示命令式命令的语法元素。 (您可能听说在 C 中,许多语句(例如赋值)也是表达式。)

因此,语句必然涉及程序状态的某些更改(例如 x := 5),或者施加一些控制流(例如GOTO 10)。
您会注意到,纯函数式语言(例如 Haskell)不包含语句,而仅包含表达式。

Etymologically, the answer is yes, as Christopher pointed out.

However, I would argue that in programming, too, there is a connection. Statements (as opposed to expressions, which are syntactic elements which may be evaluated for their value) are syntactic elements representing imperative commands. (You may hear that in C, many statements (ex. assignment) are also expressions.)

As such, statements necessarily involve some change in the state of the program (ex x := 5), or the imposition of some control flow (ex GOTO 10).
You will note that a purely functional language (say, Haskell), contains no statements, but only expressions.

七七 2024-09-09 03:26:05

它源自“state”的动词意义

It derives from the verb sense of "state".

过潦 2024-09-09 03:26:05

命令式编程范式的关键概念是程序由语句序列表示,其中语句之一会更改程序状态。

因此,您可以更改状态,或者可以说您实际上用每个语句声明(声明)某些内容。对我来说,似乎 -ment 后缀在这里使用第三义(“行动的手段或工具”)。语句是在命令式程序中陈述某些内容的工具。

在普遍使用中,似乎 -ment 后缀用于其第一感觉(“行动、过程或技能”)。

The key concept of imperative programming paradigm is that programs are represented by the sequence of statements one of which change the program state.

So you change the state or you can say you actually state (declare) something with each statement. For me it seems that -ment suffix is used here in its third sense ("The means or instrument of an action"). Statements are instruments to state something in imperative program.

In universal usage it seems that -ment suffix is used in its first sense ("An action, process, or skill").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文