Why does "let" not evaluate, but just gives me #<promise>
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
anddelay
.
A non-lazy scheme will behave in the way you expect.
HTH
精彩评论