<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Here is the result of your example:<br></blockquote><div><br></div><div>$ gsc -c -target js f1.scm</div><div>$ node f1.js</div><div><br></div><div>/home/blake/gambit/f1.js:448</div><div>  print(obj);</div><div>  ^</div><div>ReferenceError: print is not defined</div><div>    at gambit_println (/home/blake/gambit/f1.js:448:3)</div><div>    at gambit_bb1_println (/home/blake/gambit/f1.js:323:3)</div><div>    at gambit_trampoline (/home/blake/gambit/f1.js:348:10)</div><div>    at Object.<anonymous> (/home/blake/gambit/f1.js:688:1)</div><div>    at Module._compile (module.js:456:26)</div><div>    at Object.Module._extensions..js (module.js:474:10)</div><div>    at Module.load (module.js:356:32)</div><div>    at Function.Module._load (module.js:312:12)</div><div>    at Function.Module.runMain (module.js:497:10)</div><div>    at startup (node.js:119:16)</div><div>$ </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
In any case, here is a simple example and instructions on how to run the code in a JS shell and in the browser.  If you want to use non-primitive predefined Scheme library functions (such as equal?, append, map, write, etc) you will need to look into univ-lib .  The goal is to have all of this neatly packaged in gsc so that one invocation of gsc will do all that is necessary.  One issue is linking… should the .js file contain all of the application code including Scheme libraries, or should it contain just the code for the compiled file (so that it can be dynamically loaded by the web page)?  Both should be supported with an appropriate compile flag.<br>
<br>
Marc<br>
<br>
<br>
;; File: fib.scm<br>
;;<br>
;; compile with: gsc -c -target js fib.scm<br>
;;<br>
;; execute with: d8 fib.js<br>
;;<br>
;; or use it in an HTML page like this:<br>
;;<br>
;; <!DOCTYPE html><br>
;; <html><br>
;; <head><br>
;;     <title>fib</title><br>
;;     <script type="text/javascript"><br>
;;         function print(x) { console.log(x); }<br>
;;     </script><br>
;;     <script type="text/javascript" src="fib.js"></script><br>
;; </head><br>
;; <body></body><br>
;; </html><br>
<br>
(declare<br>
  (standard-bindings)<br>
  (extended-bindings)<br>
  (not safe)<br>
  (fixnum)<br>
  (block)<br>
)<br>
<br>
(define (fib n)<br>
<br>
  (define (fib n)<br>
    (if (< n 2)<br>
        n<br>
        (+ (fib (- n 1))<br>
           (fib (- n 2)))))<br>
<br>
  (fib n))<br>
<br>
(define start (real-time-milliseconds))<br>
<br>
(println (fib 30))<br>
<br>
(define end (real-time-milliseconds))<br>
<br>
(println (- end start))<br>
<br>
</blockquote></div><br></div></div>