我正在做一项家庭作业,要求我们用我们开发的某种语言(使用Scheme)实施一种称为按名称致电"的评估策略.
I'm working on a homework assignment where we are asked to implement an evaluation strategy called "call by name" in a certain language that we developed (using Scheme).
我们在Scala中得到了一个示例,但我不知道该怎么做按名称呼叫"有效,与按需求呼叫"有何不同?
We were given an example in Scala, but I don't understand how "call by name" works and how it is different to "call by need"?
推荐答案按需呼叫是按名称呼叫的记忆版本(请参见维基百科).
Call-by-need is a memoized version of call-by-name (see wikipedia).
在按名称调用中,每次使用该参数时都会对参数进行评估 ,而在按需调用方式中,参数将在首次使用时进行评估,并记录该值随后无需重新评估.
In call-by-name, the argument is evaluated every time it is used, whereas in call-by-need, it is evaluated the first time it is used, and the value recorded so that subsequently it need not be re-evaluated.
更多推荐
什么是“按姓名致电"?
发布评论