<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>On Aug 8, 2009, at 4:52 PM, Robby Findler wrote:</div><blockquote type="cite">Do you get a stacktrace with the error message?</blockquote><div><br></div><div>Not in the test frame. &nbsp;But I do if I attempt to paste it into the Interactions REPL. &nbsp;See below.</div><div><br></div><div>I'd been kind of wondering how I might figure out where a #f is being passed in place of an editor, without making changes to the private code -- tricky (or at least tedious) given all the callbacks involved, and didn't seem worth it for an uncertain payoff before inquiring here.</div><div><br></div><div>jmj<br><div><br></div><div>-------</div><div><div>set-editor method of editor-snip%: expects argument of type &lt;interface:editor% instance>; given #f</div><div><br></div><div>&nbsp;=== context ===</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/editor-snip.ss:125:2: set-editor method in editor-snip%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/snip.ss:1178:2: read method in editor-snip-class%</div><div>for-loop</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/editor.ss:600:2: read-snips-from-file method in editor%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/editor.ss:1034:2: do-buffer-paste method in editor%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/text.ss:2055:2: do-paste method in text%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/text.ss:2087:2: core</div><div>/Applications/PLT Scheme v4.2/collects/framework/private/standard-menus.ss:382:4: edit-menu:paste-callback method in ...te/standard-menus.ss:179:2</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:485:2: chain-handle-key-event method in keymap%</div><div>for-loop</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:485:2: chain-handle-key-event method in keymap%</div><div>for-loop</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:485:2: chain-handle-key-event method in keymap%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxme/keymap.ss:441:2: handle-key-event method in keymap%</div><div>/Applications/PLT Scheme v4.2/collects/mred/private/wxmenu.ss:56:23</div><div>/Applications/PLT Scheme v4.2/collects/scheme/private/more-scheme.ss:155:2: call-with-break-parameterization</div><div>...</div><div>-----------</div><div><br></div></div><div><br><div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font><br><br>Robby<br><br>On Sat, Aug 8, 2009 at 1:57 AM, Jordan Johnson&lt;<a href="mailto:jmj@fellowhuman.com">jmj@fellowhuman.com</a>> wrote:<br><blockquote type="cite">Hi all,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I've been working on a snip implementation (representing an annotated<br></blockquote><blockquote type="cite">expression) and am getting a mysterious error. &nbsp;I'd be grateful for any help<br></blockquote><blockquote type="cite">the community can offer in solving the problem.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The error: &nbsp;Currently when I attempt to copy and paste my snip, I get the<br></blockquote><blockquote type="cite">error<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;set-editor method of editor-snip%: expects argument of type<br></blockquote><blockquote type="cite">&lt;interface:editor% instance>; given #f<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">...and the editor-snip% in question is apparently not any of the snips I've<br></blockquote><blockquote type="cite">defined, which I've verified by overriding their set-editor method. &nbsp;This<br></blockquote><blockquote type="cite">error is coming from somewhere deep in MrEd, and (after embarrassingly many<br></blockquote><blockquote type="cite">hours of reading internal code and probing/rewriting) I don't see the cause.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Below is a version I've pared down to just what's necessary to see the<br></blockquote><blockquote type="cite">structure and exercise the bug. &nbsp;To reproduce the error: &nbsp;run it, evaluate<br></blockquote><blockquote type="cite">(test-w/text%), and attempt to copy and paste the editor-snip% you see in<br></blockquote><blockquote type="cite">the frame it created.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any observations?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks,<br></blockquote><blockquote type="cite">jmj<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;;;;; code-desc-simplified.ss<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">#lang scheme/gui<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(require framework embedded-gui)<br></blockquote><blockquote type="cite">(provide anno-snip%)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;;;;;;;; Snipclassery (for cut/paste) ;;;;;;;;;;;<br></blockquote><blockquote type="cite">;; Design follows framework/private/comment-box.ss lines 23-31<br></blockquote><blockquote type="cite">(define anno-snipclass%<br></blockquote><blockquote type="cite">&nbsp;(class decorated-editor-snipclass%<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define/override (make-snip stream-in) (new anno-snip%))<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define/override (read in)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(let ([pb (new anno-pb%)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(let ([code-ed (send pb get-code-editor)]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[anno-ed (send pb get-anno-editor)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send code-ed read-from-file in 'start)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send anno-ed read-from-file in 'start))))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp;(super-new)))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(define snipclass (make-object anno-snipclass%))<br></blockquote><blockquote type="cite">(send snipclass set-version 1)<br></blockquote><blockquote type="cite">(send snipclass set-classname "code-desc-snip.ss")<br></blockquote><blockquote type="cite">(send (get-the-snip-class-list) add snipclass)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;; Snip representing an annotated chunk of code.<br></blockquote><blockquote type="cite">(define anno-snip%<br></blockquote><blockquote type="cite">&nbsp;(class decorated-editor-snip%<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define/override (make-editor) (new anno-pb%))<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define/override (make-snip) (new anno-snip%))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp;;; copy/paste:<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(inherit get-editor)<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define/override (write stream-out)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(let ([pb (get-editor)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(let ([code (send pb get-code-editor)]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[anno (send pb get-anno-editor)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send code write-to-file stream-out)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send anno write-to-file stream-out))))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define/override (copy) ;; -> anno-snip%<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; return a copy of this snip<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(let ([s (new anno-snip%)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(send s set-editor (send (get-editor) copy-self))<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;s))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp;(super-new)<br></blockquote><blockquote type="cite">&nbsp; &nbsp;))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(define anno-pb%<br></blockquote><blockquote type="cite">&nbsp;(let ()<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define (find-owner-snip ed) ;; editor&lt;%> -> (union #f editor-snip%)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(let ([admin (send ed get-admin)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(and admin<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (admin . is-a? . editor-snip-editor-admin&lt;%>)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (send admin get-snip))))<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(define scheme+copy-self% &nbsp; &nbsp;;; class for the code editor<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(class scheme:text% &nbsp; &nbsp; &nbsp; &nbsp;;; (from framework/private/comment-box.ss)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(inherit copy-self-to)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(init-field [kind 'default])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(define/override (copy-self)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(let ([ed (new scheme+copy-self%)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(copy-self-to ed)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ed))<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(super-new)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(inherit set-max-undo-history)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(set-max-undo-history 'forever)))<br></blockquote><blockquote type="cite">&nbsp; &nbsp;(class aligned-pasteboard%<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(super-new)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;;;;;;; Component editors:<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; code-editor and anno-editor are the two text%s that contain the<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; code and annotation, respectively.<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; -> (union #f text%)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define/public (get-code-editor) code-editor)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define/public (make-code-editor) (new scheme+copy-self%<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [kind 'code]))<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; -> (union #f text%)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define/public (get-anno-editor) anno-editor)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define/public (make-anno-editor) (new text%))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define code-editor (make-code-editor)) &nbsp;;; code box's editor<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define anno-editor (make-anno-editor)) &nbsp;;; annotation box's<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;;;;;;; Container snips for the text editors:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define val (new vertical-alignment% [parent this]))<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; Container for the code box. &nbsp;I'm using this for the ability to<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; show/hide the box:<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define code-view (new vertical-alignment%<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [parent val]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [show? #t]))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; Installs stretchable editor snips, if none are already installed,<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; to contain the code and anno editors.<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; (Does nothing if they already are installed, and returns #f.)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;; Returns #t if successful.<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define (init-snips)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(and (not (or (find-owner-snip code-editor)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(find-owner-snip anno-editor)))<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (let ([code-snip (new stretchable-editor-snip%<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [editor code-editor]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [with-border? #t]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [min-width 50])]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [anno-snip (new stretchable-editor-snip%<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [editor anno-editor]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [with-border? #f]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [min-width 50])])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (make-object snip-wrapper% code-view code-snip)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (make-object hline% code-view)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (make-object snip-wrapper% val anno-snip)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #t)))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(init-snips)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;;;;;;;;;; copy+paste ;;;;;;;;;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp;(define/override (copy-self)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp;(let ([ed (new anno-pb%)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(let ([ed-code (send ed get-code-editor)]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[ed-anno (send ed get-anno-editor)])<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send (get-code-editor) copy-self-to ed-code)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(send (get-anno-editor) copy-self-to ed-anno)<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ed)))<br></blockquote><blockquote type="cite">&nbsp; &nbsp;)))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br></blockquote><blockquote type="cite">(define (test-w/text%)<br></blockquote><blockquote type="cite">&nbsp;(define test-snip (new anno-snip%))<br></blockquote><blockquote type="cite">&nbsp;(define test-pb (send test-snip get-editor))<br></blockquote><blockquote type="cite">&nbsp;(define txt (new scheme:text%))<br></blockquote><blockquote type="cite">&nbsp;(define f (mk-test-frame))<br></blockquote><blockquote type="cite">&nbsp;(define c (new editor-canvas% [parent f][editor txt]))<br></blockquote><blockquote type="cite">&nbsp;(send txt insert "\n(* x 3)\n4))" 0)<br></blockquote><blockquote type="cite">&nbsp;(send txt insert test-snip 0)<br></blockquote><blockquote type="cite">&nbsp;(send txt insert "(define (f x)\n(+ " 0)<br></blockquote><blockquote type="cite">&nbsp;(send txt tabify-all)<br></blockquote><blockquote type="cite">&nbsp;(send f show #t)<br></blockquote><blockquote type="cite">&nbsp;)<br></blockquote><blockquote type="cite">(define (mk-test-frame)<br></blockquote><blockquote type="cite">&nbsp;(new frame% [label "ah"] [width 500] [height 300]<br></blockquote><blockquote type="cite">&nbsp; &nbsp; &nbsp; [alignment '(center center)]))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_________________________________________________<br></blockquote><blockquote type="cite">&nbsp;For list-related administrative tasks:<br></blockquote><blockquote type="cite">&nbsp;<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br></div></div></body></html>