1 (define (attach-tag type-tag contents)
4 (cons type-tag contents)))
6 (define (apply-generic op . args)
7 (let ((type-tags (map type-tag args)))
8 (let ((proc (get op type-tags)))
10 (apply proc (map contents args))
11 (error "No method for these types -- APPLY-GENERIC"
12 (list op type-tags))))))
14 (define (apply-generic op . args)
15 (let ((type-tags (map type-tag args)))
16 (let ((proc (get op type-tags)))
18 (apply proc (map contents args))
19 (if (= (length args) 2)
20 (let ((type1 (car type-tags))
21 (type2 (cadr type-tags))
24 (let ((t1->t2 (get-coercion type1 type2))
25 (t2->t1 (get-coercion type2 type1)))
27 (apply-generic op (t1->t2 a1) a2))
29 (apply-generic op a1 (t2->t1 a2)))
31 (error "No method for these types"
32 (list op type-tags))))))
33 (error "No method for these types"
34 (list op type-tags)))))))