|
|
|
|
|
by diskzero
1724 days ago
|
|
That is a bummer about the expired certificate. You can access the site using http instead of https if you are comfortable doing so. I have never seen this live REPL before and have just used their Github repo to get the latest: https://github.com/gambit/gambit I think it is great someone is trying to get Racket compiling to Javascript again. I also agree with you about the REPL; while it is interesting to compile Racket to JS, having a REPL, a live environment and all the features of something like ClojureScript has much more utility. |
|
The last part of the demo shows how to use threads in the browser and also the JavaScript FFI. The FFI based on an infix syntax is explained in greater detail in this ELS'21 paper: http://www.iro.umontreal.ca/~feeley/papers/BelangerFeeleyELS... . The paper contains several examples. Here's a simple one you can type at the REPL:
(define message "<h1 id=\"title\">hello!</h1>")
\document.body.insertAdjacentHTML("afterbegin", `message)
\document.getElementById("title").innerText=`(object->string (expt 2 100))
Basically a backslash switches to JavaScript (with infix syntax) and a backquote switches back to Scheme (with prefix syntax).
The whole Gambit system fits in a 640KB gzipped JavaScript file, so it is reasonably fast to load.
If you are interested in a really tiny Scheme implementation in JavaScript that supports tail-calls and call/cc and an incremental Scheme compiler and a REPL and most of the R4RS procedures, you might want to try out the Ribbit Scheme implementation which is just under 6 KB of (non-gzipped) JavaScript: https://udem-dlteam.github.io/ribbit/repl-max.html . That implementation is described in a paper at the VMIL'21 workshop (presentation on October 19).