[plt-scheme] Does the copy method work differently?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Dec 15 01:16:32 EST 2003

The copy method of an editor% and the copy method of a snip don't have
much to do with each other. The editor% copy method corresponds to the
edit|copy menu item. The editor-snip% copy method is a generic factory

It's true that on some platforms (and I'm not up to date which ones
anymore) the editor's copy method calls some editor-snip%s copy
methods, but it doesn't have to. It may instead marshall the snips
using the write-to-stream and read-from-stream methods.

In general, if you produce a subclass of snip% (incl. editor-snip%)
that does not follow all of the rules listed in the documentation for
snip% (there are several methods to override listed there) then things
may well break in surprising ways. It's hard to track down precisely
what breaks and how.


At Sun, 14 Dec 2003 20:39:14 -0500, "Mike T. Machenry" wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> I am confused as to why this program produces false. Does the copy method
> work differently from the way I think it does?
> (define mysnip%
>   (class editor-snip%
>     (inherit get-editor)
>     (define/override (copy)
>       (let ([e (new text%)])
>         (send (get-editor) copy-self-to e)
>         (new mysnip% (editor e))))
>     (super-new)))
> (define e (new text%))
> (define t (new mysnip%))
> (send e insert t)
> (send (send t get-editor) insert "test")
> (send e select-all)
> (send e copy)
> (send e paste)
> (string=? "test" (send (send (send e find-first-snip) get-editor) get-text))
> -mike

Posted on the users mailing list.