Arc Forumnew | comments | leaders | submitlogin
4 points by rocketnia 4681 days ago | link | parent

That "reference to undefined identifier: _M" error happens for me all the time. If I copy from a CRLF source into a console window on Windows XP, and then I complete the entry by just pressing enter, then all the versions of MzScheme/Racket I've used get confused about what counts as a newline. They apparently treat carriage returns as a capital M (in MzScheme) or a capital R (in Racket v5.1.1).

Scary that the letter corresponds with the name of the application. ^^; Actually, by the time the Racket rename happened, I was already in the habit of working around this by including newlines at the end of what I was pasting, so I never noticed Racket treated it as an R until just now....

  Welcome to Racket v5.1.1.
  >
  (define (foo R) (+
    1 2 3))
  > (foo 1000)
  1006
  >
The string I pasted there was:

  "\r\n(define (foo R) (+\r\n  1 2 3))"
Then I pressed enter. So more accurately, it treats \r as some amount of whitespace followed by a capital R.

  >
  "
  "
  
  )
  "
  "\r\nR\r\n\r\n)\r\n"
  >
The string I pasted there was:

  "\r\n\"\r\n\""
And then I followed it by typing [enter][enter][)][enter]["][enter], trying to get Racket to recognize my input as a full command.

So okay, more accurately: It treats matches of the regex /\r\n./ as though they're "\r\nR".



2 points by jsgrahamus 4681 days ago | link

In my case, I typed everything into Arc. And I still got that error.

-----

1 point by rocketnia 4681 days ago | link

Nice. Since we're on different versions of Windows, I can totally believe that. But you only got it for one definition of factorial and not the other? Did you type them in differently somehow? (Say, by putting a newline at the beginning of the second one, or by entering the first one as the very first command of the REPL session?)

-----

[deleted]
1 point by rocketnia 4681 days ago | link

Actually, there's a chance I may be able to even though I'm on XP, since it may have more to do with the version of MzScheme being used. I'll see what I can do.

EDIT: Nope, no luck.

-----

1 point by akkartik 4681 days ago | link

Ah, so the difference in the two examples is just that one was pasted! That makes sense, thanks a lot.

When I open a dos file in vim the extra CR is sometimes rendered as ^M. I wonder if the _M has something to do with that.

-----

1 point by rocketnia 4681 days ago | link

I think that was my original theory. I probably even saw the R at some point, thought it came about because of the \r escape sequence, and forgot it wasn't like that all along.

Keep in mind that the underscore is added by the Arc compiler though. The M or R is being successfully compiled as a global variable reference. ^_^

  Use (quit) to quit, (tl) to return here after an interrupt.
  arc>
  '(
  Pocket-N/A)
  (Rocket-N/A)
  arc>

-----