-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusic~
31 lines (25 loc) · 881 Bytes
/
music~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#lang racket
; OOP Helper methods
; Instantiate method
(define (new-instance class . parameters)
(let ((instance (apply class parameters)))
(virtual-operations instance)
instance))
; Arrange for virtual operations in object
(define (virtual-operations object)
(send 'set-self! object object))
;
(define (new-part class . parameters)
(apply class parameters))
;
(define (method-lookup object selector)
(cond ((procedure? object) (object selector))
(else (error "Inappropriate object in method-lookup: " object))))
(define (send message object . args)
(let ((method (method-lookup object message)))
(cond ((procedure? method) (apply method args))
((null? method) (error "Message not understood: " message))
(else (error "Inappropriate result of method lookup: " method)))))
; Classes
(define (element length start-time)
(let