[gambit-list] javascript backend

Marc Feeley feeley at iro.umontreal.ca
Mon Jun 30 17:56:18 EDT 2014


The JavaScript backend does not include a full runtime library (which defines standard procedures such as map, append, +).  You can get around this, up to a certain point, for simple primitives like cons, car, fx+ by prefixing your code with a declaration such as

(declare (standard-bindings) (extended-bindings) (fixnum) (not safe))

That way these simple primitives will be inlined (rather than calling functions bound to global variables, which is the standard Scheme semantics).

Alternatively, you could compile your code with “univ-lib” (https://github.com/feeley/univ-lib) which I am creating for this purpose.  Some people are using this for production code, so it is fairly complete (even has eval, for example).

Marc


On Jun 30, 2014, at 5:04 PM, REPLeffect <repleffect at gmail.com> wrote:

> I decided to play around with the javascript backend to see if I might
> want to try using it for some web-based programming.
> 
> So I just compiled this little do-nothing-important program to get started:
> 
> cat > test.scm
> 
> (define (do-test a b)
>  (+ a b))
> 
> (define x (do-test 1 3))
> (define y (do-test 4 3))
> 
> ^D
> 
> I ran gsc -c -target js test.scm, and then loaded the output
> javascript file into a page on Firefox (with firebug loaded to
> interact with it).
> 
> After loading the page, I get this error:
> 
> ReferenceError: Gambit_bb1__2b_ is not defined
> 
> The code in the offending generated javascript is:
> 
> if (Gambit_glo['+'] === (Gambit_bb1__2b_)) {  ...
> 
> Seems obvious to me that the '+' procedure is never defined.  So I
> guess my questions are:
> 
> 1) what procedures are available to me when generating javascript?
> 
> 2) am I missing something obvious that would make gsc generate
> everything this simple program needs
> 
> Thanks for any help you can give.
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list