Gambit Scheme JavaScript target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd lib | |
$ make _gambit.js | |
$ cd .. | |
$ gsc/gsc -:=. -warnings -target js code.scm | |
$ gsc/gsc -:=. -warnings -target js -link -l lib/_gambit.js code.js | |
$ cat code_.js code.js lib/_gambit.js > p.js | |
$ node p.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare (extended-bindings)) | |
(##inline-host-declaration " | |
function rand(n) { | |
return Math.floor(n * Math.random()); | |
} | |
") | |
(define (rand n) | |
(+ 1 (##inline-host-expression "g_host2scm(rand(g_scm2host(@1@)))" n))) | |
(println (rand 6)) | |
(println (rand 6)) | |
(println (rand 6)) | |
(println (rand 6)) | |
(##inline-host-statement "console.log(@1@);" 123) | |
(##inline-host-statement "console.log(@1@);" "hello") | |
(##inline-host-statement "console.log(@1@);" 'world) | |
(##inline-host-statement "console.log(@1@);" (cons 11 22)) | |
(##inline-host-statement "console.log(@1@);" (vector 11 22 33)) | |
(##inline-host-statement "console.log(@1@);" rand) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment