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

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Dec 7 15:20:54 EST 2010


If we take it out of editor<%>, we should not encounter any problems whatsoever. It is possible that additional implements-interface checks will succeed, but I am doubtful. Other than that I can't think of any problems. 

Should Asumu try and just run the whole test suite and if it works you commit the change? 




On Dec 7, 2010, at 3:08 PM, Matthew Flatt wrote:

> 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
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev



Posted on the dev mailing list.