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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Dec 7 15:08:03 EST 2010

I think the mismatch was not intentional.

Maybe `do-copy' originally had a consistent interface, or maybe it was
written down in `editor<%>' before it became apparent that its
interface would be be specific to each different kin of editor. I can't
think of any reason to have `do-copy' in its present form in
`editor<%>'.

At Thu, 2 Dec 2010 16:29:52 -0500, Asumu Takikawa wrote:
> 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._mr
> ed/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._(((l
> ib._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.