feeley at iro.umontreal.ca
Thu Aug 15 10:58:56 EDT 2019
Good. The bug you were experiencing was due to the incorrect use of the deprecated g_scm2js and g_js2scm and your subsequent attempt to fix it by adding a “Gambit” state object to the runtime system which corrupted the Scheme stack. The correct conversion functions to use are g_scm2host and g_host2scm. These will work with the Python, PHP, etc backends.
Changing the FFI to avoid having to manually call these functions would be a nice improvement. This could be done by improving the definitions of ##inline-host-statement, ##inline-host-expression and ##inline-host-declaration in gsc/_t-univ-4.scm so that they take an optional type information (for the target languages like go and Java that benefit from or require knowing the type), like this:
(##inline-host-expression int: "@1@ + @2@" int: x int: y)
or extend the C interface to support other languages, in which case c-lambda, c-define, etc should be renamed host-lambda, host-define, etc.
> On Aug 15, 2019, at 10:07 AM, Amirouche Boubekki <amirouche.boubekki at gmail.com> wrote:
> Thanks a lot! Latest Gambit fix the issue I had.
> ref: https://scheme-live.github.io/scheme-fuss/
> Le sam. 20 juil. 2019 à 23:05, Marc Feeley <feeley at iro.umontreal.ca> a écrit :
> 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.
> > On Jul 20, 2019, at 1:05 PM, Amirouche Boubekki <amirouche.boubekki at gmail.com> wrote:
> > 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
> > 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
> >> 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
> Amirouche ~ amz3 ~ https://hyper.dev
More information about the Gambit-list