[racket-dev] Behavioral subtyping for editor<%> and its implementing classes

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Thu Dec 2 16:29:52 EST 2010

Hi all,

While writing contracts for classes in racket/gui, I noticed that the
implementations of text% and pasteboard% do not act as behavioral
subtypes of editor<%>, which both classes implement.

In particular, consider the do-copy method from editor<%>. Its contract
looks like this:

(send an-editor do-copy) → void?

However, the implementations have the following contracts:

(send a-text do-copy start end time extend?) → void?


(send a-pasteboard do-copy time extend?) → void?

That is, do-copy in editor<%> has no mandatory arguments, do-copy in
text% has four mandatory arguments, and do-copy in pasteboard% has
two mandatory arguments. Thus, the do-copy methods in text% and
pasteboard% do not implement the editor<%> interface (in the behavioral
subtyping sense) nor do they implement a common interface despite
claiming to.

There are several other examples of this issue in the same classes. (see
do-paste, paste-x-selection, etc.)

Is there a design rationale for this? Is this method not meant to
implement a common interface?


Posted on the dev mailing list.