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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Sep 10 18:47:34 EDT 2009

DrScheme's printer uses pretty-print, which does the reader shorthands.

Robby

On Thu, Sep 10, 2009 at 12:07 PM, Ryan Culpepper <ryanc at ccs.neu.edu> wrote:
> 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.
>
> Ryan
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-dev
>


Posted on the dev mailing list.