<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I'm experiencing some weirdness with print and pretty-print.<div><br></div><div>First of all, can someone please explain why these print the same thing:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font face="Courier">> (print 'hello (current-output-port) 0)</font></div><div><font face="Courier">'hello</font></div><div><font face="Courier">> (print 'hello (current-output-port) 1)</font></div><div><font face="Courier">'hello</font></div></div><div><br></div></blockquote>But these do not:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font face="Courier">> (pretty-print 'hello (current-output-port) 0)</font></div><div><font face="Courier">'hello</font></div><div><font face="Courier">> (pretty-print 'hello (current-output-port) 1)</font></div><div><font face="Courier">hello</font></div></div><div><br></div></blockquote>(notice the bottom line has no quote in front of the symbol)</div><div><br></div><div>It seems to me that <font face="Courier">(print 'hello (current-output-port) 1)</font> should not print with a single-quote in front of the symbol, but it does, as you can see above.</div><div><br></div><div><br></div><div>Consider this:</div><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font face="Courier">#lang racket</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">(define allow-quoted #t)</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">(define printable-unquoted<%></font></div><div><font face="Courier"> (interface* []</font></div><div><font face="Courier"> [[prop:custom-print-quotable 'never]</font></div><div><font face="Courier"> [prop:custom-write </font></div><div><font face="Courier"> (lambda (obj port mode)</font></div><div><font face="Courier"> (cond</font></div><div><font face="Courier"> [{eq? mode #t} (send obj custom-write port)]</font></div><div><font face="Courier"> [{eq? mode #f} (send obj custom-display port)]</font></div><div><font face="Courier"> [(or {= mode 0} allow-quoted) (send obj custom-print port)]</font></div><div><font face="Courier"> [{= mode 1} {error {string-append "printable-unquoted<%> object "</font></div><div><font face="Courier"> "called with depth of 1" }}]))]]</font></div><div><font face="Courier"> custom-write custom-display custom-print ))</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">(define test-printable%</font></div><div><font face="Courier"> (class* object% [printable-unquoted<%>]</font></div><div><font face="Courier"> (super-make-object)</font></div><div><font face="Courier"> </font></div><div><font face="Courier"> (define/public [custom-print port]</font></div><div><font face="Courier"> {display "(make-object test-printable%)" port} )</font></div><div><font face="Courier"> </font></div><div><font face="Courier"> (define/public [custom-write port]</font></div><div><font face="Courier"> {display "|;-)" port} )</font></div><div><font face="Courier"> </font></div><div><font face="Courier"> (define/public [custom-display port]</font></div><div><font face="Courier"> {custom-write port} ))) </font></div><div><font face="Courier"><br></font></div><div><font face="Courier">(struct test-printable []</font></div><div><font face="Courier"> #:property prop:custom-print-quotable 'never</font></div><div><font face="Courier"> #:methods gen:custom-write</font></div><div><font face="Courier"> [(define [write-proc strct port arg]</font></div><div><font face="Courier"> {fprintf port "(test-printable ~v)" {vector (new test-printable%)}} )])</font></div><div><font face="Courier"><br></font></div><div><font face="Courier"><br></font></div><div><font face="Courier">{print {test-printable}}</font></div></blockquote><font face="Courier"><br></font><div>If I run it with<font face="Courier"> (define allow-quoted #t) </font>then the result is:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>(test-printable '#((make-object test-printable%)))</div></blockquote><br></div><div>Notice that the declared unquotable object is printed in the middle of a quoted vector!!</div><div><br></div><div>If I set allow-quoted to #f then we confirm the obvious:</div><div><br></div><div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>(test-printable '#(. . <font color="#ff4013">printable-unquoted<%> object called with depth of 1</font></div></blockquote><br></div><div>Can anyone tell me why my prop:custom-print-quotable 'never is not being respected on my class instance?</div><div><br></div><div>Thanks,</div><div><br></div><div>Christopher</div></body></html>