开发者

Scheme: Mysterious void in pattern match

I am writing a function called annotate that uses match-lambda -- often with recursive calls to annotate. Here is one of the pattern matches:

(`(lambda (,<param1> . ,<params>) ,<stmts>)
 `(CLOSURE ENV (,<param1> . ,<params>) (lambda (ENV) ,(map annotate (map (lambda (x) (append `(,<param1> . ,<params>) (list x))) `(,<stmts>))))))

However, when this pattern is matc开发者_开发百科hed this is what returns:

'(CLOSURE
  ENV
  (x)
  (lambda (ENV)
    ((CLOSURE
      ENV
      (x y)
      (lambda (ENV) ((+ x y))))))
  #<void>)

Specifically I can't figure out where "void" is coming from. In fact, if I include the line:

,(displayln (map annotate (map (lambda (x) (append `(,<param1> . ,<params>) (list x))) `(,<stmts>))))

it prints:

((CLOSURE ENV (x y) (lambda (ENV) ((+ x y)))))

notably without "void".

If someone could tell me what the problem is it would be greatly appreciated.

Thanks.


The #<void> is the return value from displayln. Output functions in some implementations of Scheme and Racket usually return that when there is nothing meaningful to return.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜