开发者

Order of evaluation in scheme

T开发者_如何转开发his is what works:

(define obj1 (maak-object (coord 1 1) #f #f #t))
(set! karaktersenobjectenlijst (append karaktersenobjectenlijst
                                  (list (list 'object obj1)))))

> (cadar karaktersenobjectenlijst)
obj1
> (positie obj1)
{1 . 1}

This doesn't work:

> (positie (cadar karaktersenobjectenlijst))
. . vector-ref: expects type <vector> as 1st argument, 
. .   given: obj1; other arguments were: 0

How can I make it use the value obj1 when (cadar karaktersobjectenlijst) is evaluated?


The code is correct. I have replaced your functions with some dummys and it evaluates fine:

(define coord cons)
(define maak-object list)
(define positie car)

(define obj1 (maak-object (coord 1 1) #f #f #t))
(define karaktersenobjectenlijst '())
(set! karaktersenobjectenlijst (append karaktersenobjectenlijst
                                       (list (list 'object obj1))))
(cadar karaktersenobjectenlijst)

(positie obj1) #-> (1 . 1)
(positie (cadar karaktersenobjectenlijst)) #-> (1 . 1)

The problem must be in your library code or the way you use it. The Scheme evaluation works fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜