Hi, <br><br>I'm getting an error when I try to use 'apply' on an inherited method:<br><br><span style="font-family: courier new,monospace;">
colourwell.rkt:60:47: class: misuse of method (not in application) in: set</span><br><br>I feel I've missed something in my reading of the reference manual for apply or inheriting methods, but I don't know where I've gone wrong?<br>
<br>I'm sure this is a simple thing, but I'd love it if someone could tell me where I've gone wrong.<br><br>Seasons greetings, <br><br>Stephen<br><br>---<br><br>Details follow:<br><br>I have a little class colour% to which I'm adding a simple HSV mapping<br>
<br>I wanted to <br><span style="font-family: courier new,monospace;"> (define/public (set-hsv hue saturation value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
(apply set (hsv->rgb hue saturation value)))</span><br><br>But I had to<br><span style="font-family: courier new,monospace;"> (define/public (set-hsv hue saturation value)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
(define set-rgb (lambda (r g b) (set r g b)))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
(apply set-rgb (hsv->rgb hue saturation value)))</span><br><br>I have set the class definition to inherit 'set':<br><span style="font-family: courier new,monospace;">(define colour% (class color%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (inherit red green blue set)</span><br><br><br>-class-definition--<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define colour% (class color%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (inherit red green blue set)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (define (hsv->rgb h s v) </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (if (= s 0) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (list v v v)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (let* ((var_h (* h 6))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (var_i (floor var_h));</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (var_1 (* v (- 1 s)));</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (var_2 (* v (- 1 (* s (- var_h var_i)))));</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (var_3 (* v (- 1 (* s (- 1 (- var_h var_i)))))))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (case (floor var_h)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ((0) {list v var_3 var_1})</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ((1) {list var_2 v var_1})</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ((2) {list var_1 v var_3})</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ((3) {list var_1 var_2 v})</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ((4) {list var_3 var_1 v})</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (else {list v var_1 var_2})))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (define (rgb->hsv r g b); -> (list h s v)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define minVal (min r g b))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (define maxVal (max r g b))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define delta (- maxVal minVal))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define v maxVal)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (append </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (if (= delta 0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (list 0 0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ;; else</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (list (/ delta maxVal) ; s</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (let* (</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (del_R (/ (+ (/ (- maxVal r) 6) (/ delta 2)) delta))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (del_G (/ (+ (/ (- maxVal g) 6) (/ delta 2)) delta))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (del_B (/ (+ (/ (- maxVal b) 6) (/ delta 2)) delta))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (h (cond </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ((= r maxVal) (- del_B del_G))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ((= g maxVal) (+ (/ 1 3) del_R (- del_B)))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ((= b maxVal) (+ (/ 2 3) del_G (- del_R))))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (cond </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ((< h 0) (+ h 1))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ((> h 1) (- h 1))))))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (list v)))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (super-new)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define/public (hue)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (car (rgb->hsv (red) (green) (blue))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define/public (saturation)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (second (rgb->hsv (red) (green) (blue))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define/public (value)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (third (rgb->hsv (red) (green) (blue))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (define/public (set-hsv hue saturation value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (define set-rgb (lambda (r g b) (set r g b)))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> (apply set-rgb (hsv->rgb hue saturation value)))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ))</span><br>
<br>