[plt-scheme] class.ss positional initialization of inherited fields

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Fri Nov 1 13:11:19 EST 2002

Is there a way with PLT 200 "class.ss" to inherit initialization fields
from a superclass, such that they can be used within methods, *and* have
the inherited fields come first in the make-object positional
initialization order?

Here's one of numerous unsuccessful variations I've tried:

    (require (lib "class.ss"))

    (define a% (class* object% ()
                 (init-field        x)
                 (super-instantiate ())))

    (define b% (class* a% ()
                 (inherit-field     x)
                 (init-field        y z)
                 (define/public     (xyz) (list x y z))
                 (super-instantiate ())))

    (send (make-object b% 1 2 3) xyz)
    ==> (3 1 2) ; The positional initialization order is (y z x),
                ; but we want it to be                   (x y z).

                                                        Neil W. Van Dyke

Posted on the users mailing list.