<div dir="ltr"><div>Thanks a lot, by building gambit from source on ubuntu i make it work. <br></div><div>Do you have some pointer to make or load a windows version?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 11 févr. 2022 à 15:00, Marc Feeley <<a href="mailto:feeley@iro.umontreal.ca">feeley@iro.umontreal.ca</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Your version of Gambit is way too old.  You need the latest version (v4.9.4).  The documentation (<a href="https://gambitscheme.org/latest/manual/" rel="noreferrer" target="_blank">https://gambitscheme.org/latest/manual/</a>) gives the details on how to use the compiler.  For a simple use-case of the JavaScript backend you can do this (which executes the JavaScript code with nodejs):<br>
<br>
$ cat hello.scm<br>
(define msg "hello world!\n")<br>
(display msg)<br>
$ gsc -target js -exe -o hello.js hello.scm<br>
$ node hello.js<br>
hello world!<br>
<br>
Here is an example which executes the JavaScript code in the browser:<br>
<br>
$ cat hello-web.scm<br>
(define msg "hello world!\n")<br>
(display msg)<br>
(define (alert str) (##inline-host-statement "alert(@scm2host@(@1@));" str))<br>
(alert msg)<br>
$ gsc -target js -exe -o hello-web.html hello-web.scm<br>
$ open hello-web.html <br>
<br>
Note that by default `display` will send its output to the browser’s JavaScript console, i.e. the same place as the JavaScript console.log(…).  The last 2 lines of the program call the JavaScript `alert` function to also show the message in a dialog box.<br>
<br>
Finally, `display` can be called with the port corresponding to the web REPL (which is implemented by the Gambit runtime library through a browser dialog box):<br>
<br>
$ cat hello-web-repl.scm <br>
(define msg "hello world!\n")<br>
(display msg (repl-output-port))<br>
(##repl-debug) ;; start a REPL in a dialog box<br>
$ gsc -target js -exe -o hello-web-repl.html hello-web-repl.scm<br>
$ open hello-web-repl.html<br>
<br>
The web REPL is a good way to do “live debugging” of the Scheme program.  It also allows tinkering with JavaScript.  For example, you could get the current date at the web REPL by entering:<br>
<br>
(host-eval "new Date().toString()")<br>
<br>
There’s also a JavaScript FFI based on infix syntax for an even more user-friendly way to interface to JavaScript.  Please visit <a href="http://try.gambitscheme.org" rel="noreferrer" target="_blank">try.gambitscheme.org</a> for a demo (wait a few seconds for it to start automatically).  The demo shows off several features, such as the FFI, single-stepping, importing R7RS modules from the web, and the thread system.<br>
<br>
Marc<br>
<br>
<br>
<br>
> On Feb 11, 2022, at 5:37 AM, Jean-François Trevien <<a href="mailto:jef.trevien@gmail.com" target="_blank">jef.trevien@gmail.com</a>> wrote:<br>
> <br>
> Hello,<br>
> I tried to to use the transpiler:<br>
>  gsc -target js hello.scm<br>
> with hello.scm containing :<br>
> (display "hello word")<br>
> And i have the error message :<br>
> *** ERROR IN "hello.js"@74.39 -- Datum expected<br>
> <br>
> The version i use was install by chocolatey :<br>
> gambit v4.6.6.20121126<br>
> <br>
> what's wrong?<br>
> _______________________________________________<br>
> Gambit-list mailing list<br>
> <a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
> <a href="https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list" rel="noreferrer" target="_blank">https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list</a><br>
<br>
<br>
</blockquote></div>