I'll give an example in terms of the macro layer and the Era reader so that it's a self-contained language, not cheating with raw JavaScript code or whatnot.
However, I haven't defined any macros yet, and the macro layer would actually be entirely useless without at least one macro to use for bootstrapping. Let's say I've defined a set of macros that corresponds to the same Tenerezza syntax that the macros compile to. (This is almost silly. It's roughly analogous to writing Arc code by defining a bunch of macros that recreate Scheme.)
I'll show you what it might look like, at this point in the design, to define a function (factorial) in terms of existing functions (times factor), (plus term), (negate), (one), and (idfn).
Note that every Tenerezza function takes a single argument, but functions of tag (times factor) must be constructed with an environment that has a "factor" entry, so (times factor) is effectively a two-argument function.
Show us what factorial would look like in Tenerezza! Or some other simple thing that makes sense. Doesn't have to be a working example, and showing off cool new features is preferred but optional.
I open up a shell in Emacs (M-x shell), then run Arc manually. You have to explicitly `load` things from the REPL; there isn't any SLIME-like communication between other buffers and the shell. This doesn't seem to work right now with Anarki, but it does with Arc3.1
I think rocketnia has figured it out. Does rocketnia's comment http://arclanguage.org/item?id=19137 make sense? Basically you shouldn't get an error if you type in this expression character by character, but you should if you paste it into an arc session without a trailing <enter>.
Oh, sorry. Now that I test it, I realize I remembered incorrectly.
The only time I get those spurious R characters is when I paste code into the REPL and then press enter manually. I don't get them when typing multi-line definitions directly at the REPL, and I don't get them if the code I'm pasting already has a line break at the end.
So the habit I've formed is to make sure the code I'm pasting already has a line break at the end.
I notice this issue also happens on Racket 5.3.3 -- I'm a few versions behind -- and it does not happen in the REPLs for Node.js or Clojure. It's some kind of bug in Racket. (Hmm... Racket's port.c has a bunch of spaghetti code for CRLF processing. Maybe the bug's in there somewhere.)
So it looks like the inlined version works, but wrapping it in a function doesn't? Very strange. Paste these lines one at a time into a fresh arc session and show me what you get in response to each line.
(w/infile file "Log.txt" (drain (readline file))) ; just to set a baseline
(def foo (filename) (prn "AAA") (w/infile f filename (prn "BBB") (drain (do1 (readline f) (prn "CCC")))))
(foo "Log.txt")
(def foo (filename) (prn "AAA") (w/infile f filename (prn "BBB") (readline f)))
(foo "Log.txt")
(def read ((o x (stdin)) (o eof nil))
(if (isa x 'string) (readstring1 x eof) (sread x eof)))
; inconsistency between names of readfile[1] and writefile
(def readfile (name) (w/infile s name (drain (read s))))
(def readfile1 (name) (w/infile s name (read s)))
(def readall (src (o eof nil))
((afn (i)
(let x (read i eof)
(if (is x eof)
nil
(cons x (self i)))))
(if (isa src 'string) (instring src) src)))
My money's on the first or last one working. (Obviously this assumes you _have_ a `C:\users` directory) I would similarly bet that you might need to capitalize the drive, even though Windows drive letters are case insensitive (https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...). So if it doesn't work with lowercase letters, try it as above.
I've seen this before. What's happening, somehow, is that every time you write more than one line in a definition at the REPL in a Windows prompt, a capital R is being inserted at each newline. Arc compiles this to the Racket code _R, and when Racket executes this, it can't find the _R variable.
I seem to remember I used work around this by always pasting my multi-line definitions from a text editor rather than writing them directly at the REPL.
Can you try it without the drain, just read the first line from the file?
Edit 10 minutes later: here's a few things I would try:
; a relative path with no slashes/backslashes
(read-all "mccf2.txt")
; inline read-all
(w/infile file "mccf2.txt" (drain (readline file)))
; try reading just the first line
(w/infile file "mccf2.txt" (readline file))
Yeah, I run arc3.1 for several reasons -- including that anarki doesn't work in Emacs's shell, and I haven't taken the time to figure out^1 why: my hypothesis is that simply removing rlwrap would fix it, but I so rarely use Arc these days I haven't dealt with it.
[1] Nor have I taken the time to respond to your emails from months ago. I'm sorry about that; it's related (among other things) to some general malaise I'm trying to deal with.