[racket-dev] image snips and pretty-print (#lang htdp/bsl and snips)

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Thu Sep 1 16:22:15 EDT 2011

How are image snips and pretty-print supposed to interact?


I've isolated the bug that's been preventing image snips from printing
in something like:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang htdp/bsl
(require 2htdp/image)
(circle 20 'solid 'green)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


>From what I can tell, the print-convert-handler is doing the right
thing in leaving the image alone, but then the image snip gets printed
via pretty-print, and from what I see in:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket/base
(require 2htdp/image
         racket/pretty)

(write (circle 20 'solid 'green))
(newline)
(print (circle 20 'solid 'green))
(newline)
(pretty-print (circle 20 'solid 'green))
(newline)
(pretty-write (circle 20 'solid 'green))
(newline)
(pretty-display (circle 20 'solid 'green))
(newline)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


None of the pretty functions like image snips and print them out
textually rather than graphically!

As far as I can tell, pretty-print appears to be hardcoded to deal
with text, not snips.  Is that true?




If I comment out the setting of the current-print parameter in htdp/bsl/runtime,

##################################################################
diff --git a/collects/htdp/bsl/runtime.rkt b/collects/htdp/bsl/runtime.rkt
index d612aad..f3c96a1 100644
--- a/collects/htdp/bsl/runtime.rkt
+++ b/collects/htdp/bsl/runtime.rkt
@@ -56,7 +56,7 @@
                             (string-length img-str)
                             (oh val display? port))))])
       (thunk)))
-  (current-print
+  #;(current-print
    (lambda (v)
      (unless (void? v)
        (define converted (print-convert v))
##################################################################



then the program:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang htdp/bsl
(require 2htdp/image)
(circle 20 'solid 'green)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

behaves properly in DrRacket and prints out fine.


Posted on the dev mailing list.