[plt-scheme] Fund with override and augment

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Mon Sep 8 07:59:49 EDT 2008

Hi all,

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%.

I got tripped up by this because I rewrote some code a couple of  
times, switching from overriding to augmenting and vice versa, and my  
changes to different classes got out of sync. To make matters more  
complicated I was using mixins and one of them was switching from  
augmenting to overriding when it shouldn't have been.

Now, I'm not familiar with the origins or history of augmentable  
methods. I'm not sure if this is an oddity or what. Does anyone have  
any thoughts on this? In particular, is the behaviour shown above  
"correct" (for any given definition of the term)?

Cheers,

-- Dave


Posted on the users mailing list.