[racket] flush is not enough, a list is needed

From: Laurent (laurent.orseau at gmail.com)
Date: Mon Nov 5 03:41:52 EST 2012

On Fri, Nov 2, 2012 at 7:48 PM, Laurent <laurent.orseau at gmail.com> wrote:

>  You're using just `write', so you need some whitespace between items:
>> > (with-input-from-string
>>       (with-output-to-string (λ() (write 'x) (write 'y)))
>>     read)
>> 'xy

> Wow, thanks a lot, I would have never thought about that. I thought that
> 'write' was sending data, not mere characters.
> Writing a space after each output indeed solves the problem.

For reference, one needs to use (printf " ")  or (display " ") but not
(write " ") or (print " "), because, IIUC, 'write' does send data, but does
not add delimiters to the data if there are none yet.
I.e., a string like " " is self-delimited, a list (a b c) is also
self-delimited, but symbols and numbers are not. This means that the
delimiter must be added by hand.
'display' sends a space to the stream, whereas 'write' sends a
self-delimited data string " ".

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121105/4262ab5e/attachment-0001.html>

Posted on the users mailing list.