[plt-dev] strange behavior with printf, format, and unsyntax

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Thu Sep 10 13:07:07 EDT 2009

Sam TH wrote:
> This program:
> #lang scheme
> (display (format "~a~n" '(scheme #,3)))
> (format "~a~n" '(scheme #,3))
> (printf "~a~n" '(scheme #,3))
> Produces these results:
> (scheme (unsyntax 3))
> "(scheme (unsyntax 3))\n"
> (scheme #,3)
> which rather surprised me.  Why is `printf' behaving differently from `format'?

You ran this in DrScheme, right? They're the same in mzscheme.

Output ports have procedures associated with them (see 
'port-print-handler') to customize printing. That's how, for example, 
printing a syntax object can result in a snip being inserted into an 
editor. I guess DrScheme's output port also does reader abbreviations. 
This might be connected to the output style language preference.


Posted on the dev mailing list.