Marc,

   Thanks for the example.

   When I ran it, I got the following:

steve@steve-Satellite-L555D ~ $ js fib.js
js: uncaught JavaScript runtime exception: TypeError: Cannot find function real-time-milliseconds in object [object Object].

I'm running Gambit 4.6.7 on a 64-bit Linux Mint 14.


Steve


From: Marc Feeley <feeley@iro.umontreal.ca>
To: Mikael <mikael.rcv@gmail.com>
Cc: gambit-list@iro.umontreal.ca
Sent: Monday, September 16, 2013 9:29 PM
Subject: Re: [gambit-list] Efficient Compilation of Tail Calls and Continuations to JavaScript


On 2013-09-09, at 9:33 AM, Mikael <mikael.rcv@gmail.com> wrote:

> Awesome.
>
> For reference, is the implementation of Gambit2JS available anywhere?
>

Yes.  It is in the standard release of Gambit.  You need to use the option "-target js" to gsc.  For example:

% cat fib.scm
(declare
  (standard-bindings)
  (extended-bindings)
  (not safe)
  (fixnum)
  (block)
)

(define (fib n)

(define (fib n)
  (if (< n 2)
      n
      (+ (fib (- n 1))
        (fib (- n 2)))))

(fib n))

(define start (real-time-milliseconds))

(println (fib 30))

(define end (real-time-milliseconds))

(println (- end start))
% gsc -c -target js fib.scm
% js fib.js
832040
2035

Marc

_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list