Small fixes to match requered pattern

This commit is contained in:
Brieuc Dubois 2024-04-25 12:03:49 +02:00
parent d121b0d1e9
commit 6ffbd22c25
3 changed files with 9 additions and 10 deletions

BIN
project-2/instructions.pdf Normal file

Binary file not shown.

View File

@ -37,16 +37,15 @@
((obj (car args)) (car (cdr args)))) ; Extracting the second argument
(display (string-append "Inappropriate receiver object: " (symbol->string obj) "\n"))))
(define (method-lookup reciever message . args)
(display (null? args))
(if (= (length args) 1)
((reciever message))
((reciever message)(car args))
(define (method-lookup reciever message)
(if (= (length message) 1)
((reciever (car message)))
((reciever (car message)) (car (cdr message)))
))
(define (send reciever message . args)
(define (send reciever . message)
(if (procedure? reciever)
(method-lookup reciever message args)
(method-lookup reciever message)
(display (string-append "Inappropriate receiver object: " (symbol->string reciever) "\n"))
)
)
@ -62,6 +61,6 @@
(send p 'info) ; (point 4 6)
(send 'not-a-point 'info) ; should display "Inappropriate receiver object"
(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 'getx) ; returns 5