[plt-scheme] class.ss: super vs this methods

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Fri Aug 4 22:55:22 EDT 2006

Carl Eastlund wrote:
> On 8/4/06, Jon Rafkind <workmin at ccs.neu.edu> wrote:
>> Could (this) be made to work in the same way as (super) if supplied in
>> the procedure position? Or would it be possible to just call (foo) and
>> have it resolve to the correct method in the virtual table?
>> (foo arg1 arg2)
> See section 4.5.1 of the MzLib manual in Help Desk: that's the first
> way it lists to apply a method inside the body of a class.  Try it
> out.
I mean you cant refer to a function not declared explicitly in the scope
of the class you are using without using (super) or (send this)

(define base
  (class* object% ()
    (public foo)

    (define (foo) (printf "Hello from base\n"))))

(define child
  (class* object% ()


reference to undefined identifier: foo

If this case is to trivial since you could just use (super), imagine if
another class subclassesd child, say child2,  then when the child
constructor runs and tries to invoke the virtual method (foo) it should
see child2's foo and not base's foo.

Posted on the users mailing list.