[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?
http://pre.racket-lang.org/docs/html/gui/editor___.html?q=do-copy#(meth._(((lib._mred/main..rkt)._editor~3c~25~3e)._do-copy))

However, the implementations have the following contracts:

(send a-text do-copy start end time extend?) → void?
http://pre.racket-lang.org/docs/html/gui/text_.html?q=do-copy#(meth._(((lib._mred/main..rkt)._text~25)._do-copy))

and

(send a-pasteboard do-copy time extend?) → void?
http://pre.racket-lang.org/docs/html/gui/pasteboard_.html?q=do-copy#(meth._(((lib._mred/main..rkt)._pasteboard~25)._do-copy))

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?

Cheers,
Asumu


Posted on the dev mailing list.