[plt-scheme] inheritance of private fields?
Hello all:
Here's a maybe simpler version of my question. This code does what I
want it to do, except that I can't seem to redefine the inherited weight
field. define doesn't do it, and set! doesn't do it, and inherit-field
chokes when I try (inherit-field (weight 3)). There must be something I
can use on the >>>> line below, but what?
I'm sure I'm being stupid here, but I really don't know what else to
try, and don't really understand why what I've tried doesn't work. I've
asked that the field be inherited, why doesn't that make the name
available within the fsize% definition?
Also, *is* the order guaranteed in init-field?
Many thanks for the help,
-tom
(define size%
(class* object% ()
(public print-name print-age print-weight)
(init-field (name 'Fred) (bday 070661))
(field (weight 0))
(define age (calculate-age bday))
(define (print-name) (display name))
(define (print-age) (display age))
(define (print-weight) (display weight))
(super-new)))
(define (calculate-age n) 33)
(define fsize%
(class* size% ()
(inherit print-name print-age print-weight)
(inherit-field weight)
>>>> (set! weight 3)
(super-new)))
(define g (new size% (name 'Bert) (bday 45)))
(define h (new fsize% (name 'Susan) (bday 43)))
(send g print-name)
(send h print-name)
(send g print-weight)
(send h print-weight)
--
------------------------
tomfool at as220 dot org
http://sgouros.com
http://whatcheer.net