[gambit-list] javascript backend

REPLeffect repleffect at gmail.com
Tue Jul 1 11:05:02 EDT 2014


Cool!  Thanks, Marc.

I figured something like that was probably the reason for the error.
I think the univ-lb solution is the one I'll probably opt for.

Is there any obvious documentation on the javascript backend that I've
missed?  I have looked on the wiki, and the mailing list archive, but
other than the paper "Efficient Compilation of Tail Calls and
Continuations to JavaScript", I haven't really seen anything.

I'm assuming there will be a general overview of how to use the
javascript backend in the manual at some point.  Have you considered
writing a quick "getting started" page on the wiki, or something like
that?

Thanks again for your help.



On 6/30/14, Marc Feeley <feeley at iro.umontreal.ca> wrote:
> 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