[plt-scheme] a snip copy/paste puzzle

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Aug 9 10:05:47 EDT 2009

At Fri, 7 Aug 2009 23:57:22 -0700, Jordan Johnson wrote:
> I've been working on a snip implementation (representing an annotated  
> expression) and am getting a mysterious error.  I'd be grateful for  
> any help the community can offer in solving the problem.

There are two layers of problems --- one yours and one mine:

 * You need to set the snipclass for each instance of `anno-snip%'
   by ending the initialization with

     (inherit set-snipclass)
     (set-snipclass snipclass)

   Also, the `read' method of your snipclass needs to create and return
   a snip:

     (define/override (read in)
       (let* ([s (new anno-snip%)]
              [pb (send s get-editor)])
         (let ([code-ed (send pb get-code-editor)]
               [anno-ed (send pb get-anno-editor)])
           (send code-ed read-from-file in 'start)
           (send anno-ed read-from-file in 'start))

   With those changes, you code works in 4.1.5.

 * There's a problem in `embedded-gui' where it registers two different
   snip classes name "make-line-snip". The editor-classes rewrite for
   v4.2 did not correctly handle multiple registrations of the same

   I've fixed both of those problems in SVN, but it means that even
   your revised code won't work in 4.2 or 4.2.1.

Of course, there's also the problem (mine) that error messages are bad
when you get part of the complicated snip machinery wrong. That will
take more work, eventually.

Posted on the users mailing list.