Arc Forumnew | comments | leaders | submitlogin
1 point by rocketnia 5029 days ago | link | parent

Rainbow.js can load arc.arc now. ^_^

There's a catch: My reader code is in continuation-passing style, and if the input's too long, it goes into a stack overflow.

Fortunately, the reason it's in CPS is so that it can process the input asynchronously. As long as it's actually working asynchronously, its continuation callbacks occur on fresh event stacks rather than piling up. I could go into more details, but what's important is that for now, submitting the input in smaller pieces is an effective, if ugly, workaround:

  var arcArc = document.getElementsByTagName( "textarea" )[ 0 ].
      value.split( "\n" );
  function readRest() {
      if ( arcArc.length === 0 ) return;
      consoleIn.o.writeString( arcArc.shift() + "\n" );
      setTimeout( readRest, 0 );
  }
  readRest();
For future reference, here's a link to the commit I'm talking about: https://github.com/rocketnia/rainbow-js/commit/60f60282b74e2...


1 point by thaddeus 5029 days ago | link

I must be doing something wrong. I tried entering only 1 line and got:

Message : Unhandled exception on thread#0: Symbol var is not bound....

-----

1 point by rocketnia 5029 days ago | link

I suspect you're entering that JavaScript code at the Arc REPL. ^^; I just pasted that JavaScript here as an excerpt of the full(er) instructions on the REPL page:

"Actually, if you you paste from Java Rainbow's arc.arc source yourself, you'll probably find that Rainbow.js encounters a stack overflow error. At this point it's necessary to enter it in more bite-size pieces. Right now you can accomplish this by pasting all of arc.arc into the input box, then entering the following code into a JavaScript console (not the Arc console!) to have it entered one line at a time:

[the JS code I pasted above]"

In Chrome, the JavaScript console is available under "(wrench icon) > Tools > JavaScript console." On Firefox, I tested it using Firebug's console tab, but I think the Error Console might work too.

Also, pasting the JavaScript snippet all at once should be fine. The point is to enter the Arc code in bite-size pieces, and the JavaScript snippet just automates that process.

I'm considering making this workaround a feature of the REPL interface, as a checkbox or something, but what I'd rather do is fix the issue altogether.

-----

1 point by rocketnia 5027 days ago | link

"what I'd rather do is fix the issue altogether."

Done! Now the reader only uses a number of JavaScript stack frames proportional to the amount of nesting of the program, rather than the number of characters. Feel free to just paste all of arc.arc into the REPL and hit enter. ^_^

I've also tested the REPL on more browsers. The only one that really had a problem was IE 8, and that was because of the code of the REPL interface itself rather than the Rainbow.js runtime. It should work in IE 8 now... except that the performance is terrible there. XD

Any ideas about where this project should go next?

-----

1 point by rocketnia 5018 days ago | link

Rainbow.js is compiling with the Closure Compiler's advanced mode now! The REPL page--which still doesn't load arc.arc--is now down to 146 KB (HTML and JavaScript), rather than over 500.

Furthermore, on most recent browsers, the loading speed seems competitive with, or even better than, the loading speed of Java Rainbow. It might not be a fair comparison, since the contents being loaded are coming through a different kind of input, but I'm still pretty excited. ^_^

-----