[gambit-list] Going forward with JavaScript Backend (Was: Information about the Gambit-C Javascript Backend)
Marc Feeley
feeley at iro.umontreal.ca
Sat Jul 20 17:04:56 EDT 2019
Quasiquote works when you link with the Gambit runtime library. If you have a custom library you need to define the procedures needed by quasiquote:
(define (##quasi-append lst1 lst2) (append lst1 lst2))
(define (##quasi-list . lst) lst)
(define (##quasi-cons obj1 obj2) (cons obj1 obj2))
(define (##quasi-list->vector lst) (list->vector lst))
(define (##quasi-vector . lst) (list->vector lst))
(define (append lst1 lst2) …)
(define (list->vector lst) …)
(define x `(1 ,(fx+ 2 3) 4))
(println (cadr x))
It will be a bit harder to get syntax-case working with the JS backend because macro definitions cause the generation of a residual call to $sc-put-cte and that would have to be implemented. It might help to contact the authors of psyntax to see if this can be avoided (I think it can but don’t know exactly how).
Concerning your issue with your counter web app, I suspect it might be due to an incorrect optimization by the JS backend of the create-app procedure’s lambdas. The tails of two of those lambdas return #t and the compiler is mergin those in the same basic block. Could you change one of the two #t to 'true, which shouldn’t affect the working of the app but prevents the optimization. If that works I’ll look into it further.
Marc
> On Jul 20, 2019, at 1:05 PM, Amirouche Boubekki <amirouche.boubekki at gmail.com> wrote:
>
> I would like to work on the JavaScript Backend.
>
> I started porting my work from JavaScript and other Schemes that rely on ReactJS
> to Gambit:
>
> https://github.com/scheme-live/scheme-fuss
>
> This is the very basic and doesn't support calling the backend yet. I
> am confident I can
> achieve it (along all the things that are listed in the issues), but I
> am hitting some problems.
>
> In particular the following features are not available:
>
> - quasiquote: this would allow to easily express html in s-expr (sxml)
>
> - syntax-case: this would allow to adapt some of my previous work
> involving R7RS libraries.
>
> Also, I upgraded my demo application to implement an application of "counter".
>
> It fails after the 10th click on increment button:
> https://scheme-live.github.io/scheme-fuss/
>
>
> tl;dr: Let me know what you think and how I can put my (plenty of)
> time to good use?
>
>
> Thanks for the great work!
>
> ---------- Forwarded message ---------
> De : Marc Feeley <feeley at iro.umontreal.ca>
> Date: ven. 19 juil. 2019 à 17:37
> Subject: Re: [gambit-list] Information about the Gambit-C Javascript Backend
> To: Amirouche Boubekki <amirouche.boubekki at gmail.com>
> Cc: Paulo Silva Filho <paulosfilho at gmail.com>, gambit-list
> <gambit-list at iro.umontreal.ca>
>
>
> Like so:
>
> % cd gambit
> % cd lib
> % make _gambit.js
> ../gsc/gsc -:~~bin=../bin,~~lib=../lib,~~include=../include -f -target
> js -prelude "(define-cond-expand-feature|enable-type-checking|)(define-cond-expand-feature|disable-auto-forcing|)(define-cond-expand-feature|enable-sharp-dot|)(define-cond-expand-feature|enable-bignum|)(define-cond-expand-feature|enable-ratnum|)(define-cond-expand-feature|enable-cpxnum|)(define-cond-expand-feature|disable-smp|)(##include\"../lib/header.scm\")"
> -o _gambit.js ../lib/_univlib.scm
> % cd ..
> % gsc/gsc -:=. -target js -exe app.scm
> % ./app
> 1
> 256
> 65536
> 16777216
> 4294967296
> 1099511627776
> 281474976710656
> 72057594037927936
> 18446744073709551616
> 4722366482869645213696
> 1208925819614629174706176
> 309485009821345068724781056
> 79228162514264337593543950336
> 20282409603651670423947251286016
> 5192296858534827628530496329220096
> 1329227995784915872903807060280344576
> 340282366920938463463374607431768211456
> 87112285931760246646623899502532662132736
> 22300745198530623141535718272648361505980416
> 5708990770823839524233143877797980545530986496
> % cat app.scm
> (define n 20)
> (for-each (lambda (i)
> (println (object->string (expt 2 (* i 8)))))
> (iota n))
> (exit)
>
> This should work for the other backends too. Note that there’s some
> bit rot of lib/univlib.scm, so there are issues with some parts of the
> Gambit library (for example write and pretty-print are broken, (exit)
> is needed to avoid an exception on exit, etc). You can revert to
> previous recent releases of Gambit to get these working correctly.
>
> Sorry but lots of things are in flux right now…
>
> Marc
>
>
>
>> On Jul 19, 2019, at 11:08 AM, Amirouche Boubekki <amirouche.boubekki at gmail.com> wrote:
>>
>> Sorry for the multiple emails!
>>
>> Le ven. 19 juil. 2019 à 13:38, Marc Feeley <feeley at iro.umontreal.ca> a écrit :
>> You should look at this recent thread: https://mailman.iro.umontreal.ca/pipermail/gambit-list/2019-July/009103.html
>>
>> In the above mail thread, it is described how to compile a scheme file into javascript WITHOUT "Gambit runtime".
>>
>> Q: How can I bundle the Gambit runtime into the compiled JavaScript file?
>>
>>
>> Thanks in advance!
>
>
>
>
> --
> Amirouche ~ amz3 ~ https://hyper.dev
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list
More information about the Gambit-list
mailing list