开发者

Why does "let" not evaluate, but just gives me #<promise>

开发者 https://www.devze.com 2022-12-16 18:55 出处:网络
Something simple as this: Welcome to DrScheme, version 4.2.3 [3m]. Language: Lazy Scheme; memory limit: 128 megabytes.

Something simple as this:

Welcome to DrScheme, version 4.2.3 [3m].
Language: Lazy Scheme; memory limit: 128 megabytes.

> (let ((x 2) (y 10))
   (+ x y))

#<promise>

> 

I press enter for开发者_JAVA技巧 the let expression, and it gives me the #<promise>. What am I doing wrong?


It says Language: Lazy Scheme;. I'm sure this means that you're using a variant of scheme that runs lazily - i.e. it doesn't evaluate an expression until the result is required. The way scheme will manage this internally will be by using scheme's promise mechanism - instead of returning the result of an expression, a promise to calculate the result later is returned. You should be able to get the result explicitly by calling force against this promise.

Here are a couple of references:

  • Wikipedia article on lazy evaluation.
  • Scheme r5rs on force and delay.

A non-lazy scheme will behave in the way you expect.

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消