comparison methods.lisp @ 18:70e76c1c87b7

Bug fixes and exports in package.lisp darcs-hash:20061213114049-f76cc-4c4175a1ad8b24e1c5df82c9fb67445ac32977d9.gz
author David Lewis <d.lewis@gold.ac.uk>
date Wed, 13 Dec 2006 11:40:49 +0000
parents 930e9880ed3f
children 2f331bbdfab8
comparison
equal deleted inserted replaced
17:930e9880ed3f 18:70e76c1c87b7
6 (defmethod timepoint ((moment-designator moment)) 6 (defmethod timepoint ((moment-designator moment))
7 (%moment-time moment-designator)) 7 (%moment-time moment-designator))
8 8
9 (defmethod span ((pitch-interval-designator pitch-interval)) 9 (defmethod span ((pitch-interval-designator pitch-interval))
10 (%pitch-interval-span pitch-interval-designator)) 10 (%pitch-interval-span pitch-interval-designator))
11
12 (defmethod chromatic-pitch ((pitch-designator chromatic-pitch))
13 pitch-designator)
14
15 (defmethod chromatic-pitch-number ((pitch-designator chromatic-pitch))
16 (%chromatic-pitch-number pitch-designator))
17
18 (defmethod chromatic-pitch-number ((pitch-designator pitch))
19 (%chromatic-pitch-number (chromatic-pitch pitch-designator)))
11 20
12 ;; Time protocol 21 ;; Time protocol
13 22
14 (defmethod time+ ((object1 moment) (object2 period)) 23 (defmethod time+ ((object1 moment) (object2 period))
15 (make-moment (+ (timepoint object1) (duration object2)))) 24 (make-moment (+ (timepoint object1) (duration object2))))
23 32
24 (defmethod time+ ((object1 moment) (object2 moment)) 33 (defmethod time+ ((object1 moment) (object2 moment))
25 (error 'undefined-action :operation 'time+ :datatype (list (class-of object1) (class-of object2)))) 34 (error 'undefined-action :operation 'time+ :datatype (list (class-of object1) (class-of object2))))
26 35
27 (defmethod time- ((object1 moment) (object2 moment)) 36 (defmethod time- ((object1 moment) (object2 moment))
28 (make-anchored-period object1 37 (make-anchored-period (timepoint object2)
29 (- (duration object2) 38 (- (timepoint object1)
30 (duration object1)))) 39 (timepoint object2))))
31 40
32 (defmethod time- ((object1 moment) (object2 period)) 41 (defmethod time- ((object1 moment) (object2 period))
33 (make-moment (- (timepoint object1) (duration object2)))) 42 (make-moment (- (timepoint object1) (duration object2))))
34 43
35 (defmethod time- ((object1 period) (object2 moment)) ;? 44 (defmethod time- ((object1 period) (object2 moment)) ;?
39 48
40 (defmethod time- ((object1 period) (object2 period)) 49 (defmethod time- ((object1 period) (object2 period))
41 (make-floating-period (- (duration object2) 50 (make-floating-period (- (duration object2)
42 (duration object1)))) 51 (duration object1))))
43 52
53 ;; these ones are less certain. I've just put them in, but think I
54 ;; should remove them and force the user to specify what they mean
55 ;; when they give objects that are both moments *and* periods to these
56 ;; functions.
57
58 (defmethod time- ((object1 anchored-period) (object2 anchored-period)) ;?
59 (time- (moment object1) (moment object2)))
60
61 (defmethod time- (object1 (object2 anchored-period)) ;?
62 (time- object1 (moment object2)))
63
64 (defmethod time- ((object1 anchored-period) object2) ;?
65 (time- (moment object1) object2))
44 66
45 (defmethod time> ((object1 moment) (object2 moment)) 67 (defmethod time> ((object1 moment) (object2 moment))
46 (> (timepoint object1) (timepoint object2))) 68 (> (timepoint object1) (timepoint object2)))
47 69
48 (defmethod time= ((object1 moment) (object2 moment)) 70 (defmethod time= ((object1 moment) (object2 moment))
53 75
54 (defmethod duration= ((object1 period) (object2 period)) 76 (defmethod duration= ((object1 period) (object2 period))
55 (= (duration object1) (duration object2))) 77 (= (duration object1) (duration object2)))
56 78
57 (defmethod duration* ((object1 period) (object2 number)) 79 (defmethod duration* ((object1 period) (object2 number))
58 (* (duration object1) object2)) 80 (make-floating-period (* (duration object1) object2)))
59 81
60 (defmethod duration* ((object1 number) (object2 period)) 82 (defmethod duration* ((object1 number) (object2 period))
61 (duration* object2 object1)) 83 (duration* object2 object1))
62 84
63 (defmethod duration/ ((object1 period) (object2 number)) 85 (defmethod duration/ ((object1 period) (object2 number))
64 (/ (duration object1) object2)) 86 (make-floating-period (/ (duration object1) object2)))
65 87
66 ;; Pitch protocol 88 ;; Pitch protocol
67 89
68 (defmethod pitch+ ((object1 pitch-designator) 90 (defmethod pitch+ ((object1 pitch-designator)
69 (object2 pitch-designator)) 91 (object2 pitch-designator))