开发者

Scheme pattern matching with match-lambda

开发者 https://www.devze.com 2023-02-13 12:38 出处:网络
I am writing a function called annotate that uses match-lambda, often with recursive calls to annotate.Here is one of the pattern matches:

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 ,(list-append `(,<param1> . ,<params>) `(,<stmts>))))))

list-append just makes new lists out of its two arguments. The problem is that when this pattern matches it returns something like:

'(CLOSURE
  ENV
  (x)
  `(lambda (ENV)
     ,(map
       annotate
       (<results of list-append>))))

Specifically, ",(map annotate" prints literally rather than being evaluated -- even though it is being unquoted. Other patterns within the function appear to use the exact same syntax without this issue. Also, the unquoted function list-append executes with no problems.

Any advice 开发者_Go百科is appreciated.


You have nested backquotes: you have one in front of CLOSURE and then a second one in front of the second lambda without a comma in between: notice the literal backquote in the middle of your output. I think removing the backquote before the second lambda will fix the problem.

0

精彩评论

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

关注公众号