什么是评价? [英] What is evaluation?

查看:60
本文介绍了什么是评价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个词上已经绊了很长时间了(man,数学,编程,makefile等).我是否正确理解该术语?评估是对某些表达式的结果的计算,例如:

a + b-表达式

要对其求值(通过数字得到一些结果),我们应像这样给变量赋值

a = 1,b = 1

从中得出的结果是"2"(这意味着我们使用输入值将表达式评估为"2"

a = 1,b = 1)

解决方案

C 2018 5.1.2.3 2说:对表达式的 Evaluation 通常包括值计算和副作用的产生."因此,是的,评估在很大程度上是根据某个表达式来计算值.在C语言中,求值还包括副作用,例如由 x ++ 引起的增量,该增量会影响 x ,但不会影响其所在表达式的值.

5.1.2.3 2继续说左值表达式的值计算包括确定指定对象的身份."这更多是关于描述C语言的语义而不是关于执行计算的知识,因此在这里我将不对其进行进一步的讨论.

6.5 1告诉我们表达式是一个运算符和操作数的序列,它们指定值的计算,或者指定对象或函数,或者产生副作用,或者执行它们的组合."因此,对于表达式的值方面,表达式指定一个计算,然后求值执行该计算.该表达式还可以指定副作用,而评估也可以执行.

I have been stumbling upon this term for a quite a while (man, math, programming, makefile, etc.) Am I understanding the term correctly? Evaluation is a calculation of the result of some expression, ex.:

a + b - expression

To evaluate it (get some result by number) we give variables value like so

a = 1, b = 1

Judging from that we get a result "2" ( which means we evaluated the expression to "2" with input values

a = 1, b = 1)

解决方案

C 2018 5.1.2.3 2 says "Evaluation of an expression in general includes both value computations and initiation of side effects." So, yes, in large part evaluation is computing the value from some expression. In C, evaluation also includes side effects, such as the increment caused by x++, which affects x but does not contribute to the value of the expression it is in.

5.1.2.3 2 goes on to say "Value computation for an lvalue expression includes determining the identity of the designated object." That is more about the semantics by which the C language is described than about performing a computation, so I will not discuss it further here.

6.5 1 tells us "An expression is a sequence of operators and operands that specifies computation of a value, or that designates an object or a function, or that generates side effects, or that performs a combination thereof." So, for the value aspect of an expression, the expression specifies a computation, and evaluation performs that computation. The expression may also specify side effects, and evaluation performs those too.

这篇关于什么是评价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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