Small fixes to match requered pattern
This commit is contained in:
parent
d121b0d1e9
commit
6ffbd22c25
Binary file not shown.
|
@ -36,4 +36,4 @@
|
||||||
(send p 'foo) ; should display "Message not understood"
|
(send p 'foo) ; should display "Message not understood"
|
||||||
(send p 'bar 2) ; should display "Message not understood"
|
(send p 'bar 2) ; should display "Message not understood"
|
||||||
(send p1 'setx! 5)
|
(send p1 'setx! 5)
|
||||||
(send p1 'getx) ; returns 5
|
(send p1 'getx) ; returns 5
|
||||||
|
|
|
@ -37,16 +37,15 @@
|
||||||
((obj (car args)) (car (cdr args)))) ; Extracting the second argument
|
((obj (car args)) (car (cdr args)))) ; Extracting the second argument
|
||||||
(display (string-append "Inappropriate receiver object: " (symbol->string obj) "\n"))))
|
(display (string-append "Inappropriate receiver object: " (symbol->string obj) "\n"))))
|
||||||
|
|
||||||
(define (method-lookup reciever message . args)
|
(define (method-lookup reciever message)
|
||||||
(display (null? args))
|
(if (= (length message) 1)
|
||||||
(if (= (length args) 1)
|
((reciever (car message)))
|
||||||
((reciever message))
|
((reciever (car message)) (car (cdr message)))
|
||||||
((reciever message)(car args))
|
|
||||||
))
|
))
|
||||||
|
|
||||||
(define (send reciever message . args)
|
(define (send reciever . message)
|
||||||
(if (procedure? reciever)
|
(if (procedure? reciever)
|
||||||
(method-lookup reciever message args)
|
(method-lookup reciever message)
|
||||||
(display (string-append "Inappropriate receiver object: " (symbol->string reciever) "\n"))
|
(display (string-append "Inappropriate receiver object: " (symbol->string reciever) "\n"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -62,6 +61,6 @@
|
||||||
(send p 'info) ; (point 4 6)
|
(send p 'info) ; (point 4 6)
|
||||||
(send 'not-a-point 'info) ; should display "Inappropriate receiver object"
|
(send 'not-a-point 'info) ; should display "Inappropriate receiver object"
|
||||||
(send p 'foo) ; should display "Message not understood"
|
(send p 'foo) ; should display "Message not understood"
|
||||||
(send p 'bar 2) ; should display "Message not understood"
|
;(send p 'bar 2) ; should display "Message not understood"
|
||||||
(send p1 'setx! 5)
|
(send p1 'setx! 5)
|
||||||
(send p1 'getx) ; returns 5
|
(send p1 'getx) ; returns 5
|
||||||
|
|
Loading…
Reference in New Issue