1
我们想从C#中使用IronScheme调用闭包方案,但是我们不断得到一个异常,并说“不是一对”。使用ironscheme调用闭包
我们想调用下面的计划代码:
(define (create-robot name)
(let* (
(position (cons 0 0))
(move-forward(lambda (x)
(set! position (cons (car position) (+ x (cdr position))))
position))
)
(list name (cons 'position position) (cons 'move-forward move-forward))));return attribute 'name' and procedure 'move-north'
(define (get-from-robot r name)
(cdr (assq name (cdr r))))
使用C#下面的代码:
Callable c1 = schemeInterpretor.getCallable("create-robot");
Cons john = (Cons)c1.Call("john");
Callable getFromRobot = schemeInterpretor.getCallable("get-from-robot");
getFromRobot.Call(john , "'position");
我们得到以下异常:
{"not a pair"} {&assertion
&who: "cdr"
&message: "not a pair"
&irritants: (#f)
}
是什么导致问题?我们如何解决它?