[racket] Problem with Racket REPL and pasting

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Sun Sep 19 22:23:22 EDT 2010

> But if I copy and paste in the same expression, I get an error:
>> (+ 1 2
>    3)
> reference to undefined identifier: R


Confirmed: I can see similar behavior in DrScheme 4.2.5 when I
copy-and-paste in Windows 7:

###################################################################

C:\Program Files (x86)\PLT>mzscheme
Welcome to MzScheme v4.2.5 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
> (+ 1 2
   3)
reference to undefined identifier: M

 === context ===
C:\Program Files (x86)\PLT\collects\scheme\private\misc.ss:74:7
####################################################################


Quick experiment: I opened up a new Command Prompt terminal.  Ran
mzscheme, and then wrote the following at the REPL:

> (let loop () (printf "~s\n" (read-byte)) (loop))


I pressed enter.  I saw the following:

13
10

which is slightly unexpected, in the sense that I expected the reader
to have already absorbed the carriage-return+newline combination, but
oh well.  Then, with my clipboard containing the content:

(+ 1 2
    3)

I pasted into the command line console and pressed enter.  Here's what shows up:

(+ 1 2
40
43
32
49
32
50
32
13
10
   3)
77
32
32
51
41
13
10




The byte stream that's observed by read-bytes is the following:

> (bytes 40 43 32 49 32 50 32 13 10 77 32 32 51 41 13 10)
#"(+ 1 2 \r\nM  3)\r\n"



No clue why "M" is being introduced into the stream.  There's
something in the handling of newlines at the Windows console
interactive REPL that is funky.


Posted on the users mailing list.