George,
   Your unicode comment made me wonder.  So I wrote out some code to the repl 
and it "compiled" and ran fine.  Next I copied that code to Notepad and then 
copied and pasted it back to the repl and it "compiled" and ran fine.  Finally 
I google "scheme factorial" and copied what I found to the repl and there I had 
problems.
   First saw this in the arc programming language, which is based on Racket.
   The funny thing is that a number of other Scheme implementations do not act 
thusly.  I wonder what can be done to remove this from Racket.


Steve
---
;; Typed into repl
> (define (fact n)
     (if (< n 2)
         1
         (* n (fact (- n 1)))))
> (fact 5)
120
;; Copied from Notepad into repl> (define (fact n)
   (if (< n 2)
       1
       (* n (fact (- n 1)))))
> (fact 5)
120
;; Copied from browser into repl> (define (factorial n)
  (if (= n 0)
      1
      (* n (factorial (- n 1)))))
stdin::355: if: bad syntax;
 has 4 parts after keyword
  in: (if (= n 0) 1 R (* n (factorial (- n 1))))
  context...:
   C:\Program Files\Racket\collects\racket\private\misc.rkt:87:7
>
     From: George Neuner <[email protected]>
 To: [email protected] 
 Sent: Tuesday, March 17, 2015 2:21 PM
 Subject: Re: [racket] Error when pasting code
   
On Tue, 17 Mar 2015 19:06:50 +0000 (UTC), Steve Graham
<[email protected]> wrote:

>When running the following code, when manually typed in, there is no
>error.  However, when the same is pasted from the keyboard buffer,
>the error indicated appears.
>Comments?
>Thanks, Steve

Likely there are hidden control characters being carried when you cut
and paste.

I've had troubles going back and forth between DrRacket and various
unicode aware code editors - everything from syntax errors compiling
to DrRacket hanging or even crashing trying to load source files.
Inevitably it is because some hidden character(s) snuck in.

I haven't actually experienced it with cut-n-paste, but it would not
surprise me.

George

____________________
  Racket Users list:
  http://lists.racket-lang.org/users


  
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to