這是我第一天在Dr.Racket
和R5RS
語言。我正在嘗試修改下面我分享的現有代碼。DrRacket:應用程序:不是程序錯誤在R5RS語言
;; This is an internal helper procedure.
;; - it gets the method out of "in-object"
;; - it invokes the method, passing "for-object" as the
;; "self" for the method.
;;
(define (apply-method in-object for-object message args)
(let ((method (get-method message in-object)))
(cond ((method? method)
(apply method for-object args))
((eq? in-object for-object)
(display method)
(error "No method for" message 'in
(safe-ask 'UNNAMED-OBJECT
in-object 'NAME)))
(else (error "Can't delegate" message
"from" (safe-ask 'UNNAMED-OBJECT
for-object 'NAME)
"to" (safe-ask 'UNNAMED-OBJECT
in-object 'NAME))))))
(define (get-method message object) ; single-inheritance
(object message))
這段代碼是相當大的項目的一部分。因此,我只分享相關部分。在項目內部,當這個apply-method
程序被調用時。以let
表達式開頭的行中出現錯誤。錯誤信息如下:
objsys.scm:53:2:application:not a procedure;預期過程 可以應用到給定的參數
:#F
參數...:
所以,我不知道是否有任何人誰可以幫我解決問題。 編輯
我懷疑有像上述誤用或不對齊paranthesis一個語法錯誤,但我無法找到導致錯誤的確切地點。
看起來問題更多的是使用'apply-method'而不是它的實現。在某處,它被應用了'#對象'。 – molbdnilo