[plt-scheme] Fund with override and augment

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Sep 8 09:16:13 EDT 2008

At Mon, 8 Sep 2008 12:59:49 +0100, Dave Gurnell wrote:
> I got tripped up by something recently and I was wondering what your  
> opinions on it were. Here's some sample code that illustrates the  
> problem I had:
> 
> #lang scheme
> 
> (define class-a%
>    (class object%
>      (define/pubment (xyz)
>        (list* 1 (inner null xyz)))
>      (super-new)))
> 
> (define class-b%
>    (class class-a%
>      (define/augride (xyz)
>        (list 2))
>      (super-new)))
> 
> (define class-c%
>    (class class-b%
>      (define/augment (xyz)
>        (list 3))
>      (super-new)))
> 
> Three classes in a hierarchy: the super class defines a method and  
> allows it to be augmented. The middle class augments it and allows it  
> to be overridden. Due to a programmer error, the third class augments  
> the method rather than overriding it.
> 
> Calling (send (new class-c%) xyz) yields '(1 3). This seems counter- 
> intuitive to me: I was expecting a compiler error for class-c%.

Yes, that should have been an error (but a run-time error in creating
the class bound to `class-c%'). I'll fix the bug soon.


Matthew



Posted on the users mailing list.