|
From: | Germán Diago |
Subject: | Re: Guile status. Some questions to adopt usage as embedded game. |
Date: | Wed, 26 Mar 2014 20:56:59 +0700 |
address@hidden (Ludovic Courtès) skribis:
> Germán Diago <address@hidden> skribis:
[...]
Here’s a session that uses the FFI from ECMAscript to bind the C
>> 4.- When writing a FFI from C++ functions, I know how guile code will
>> look, but I couldn't find any Ecmascript mapping documentation. Any
>> pointers where I could find something?
>
> In theory it should be possible to import and use Scheme functions from
> ECMAscript. See
> <http://wingolog.org/archives/2009/02/22/ecmascript-for-guile>.
library’s ‘sqrt’ function:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,L ecmascript
Happy hacking with ECMAScript! To switch back, type `,L scheme'.
ecmascript@(guile-user)> require('system.foreign');
;;; <unknown-location>: warning: possibly unbound variable `require'
$1 = #<<js-module-object> 27b94b0>
ecmascript@(guile-user)> this['dynamic-link'];
$2 = #<procedure dynamic-link (#:optional _)>
ecmascript@(guile-user)> this['dynamic-func'] ('sqrt', this['dynamic-link']());
$3 = #<pointer 0x7f5d7d79aae0>
ecmascript@(guile-user)> this['list'] ($1['double']);
$8 = (2)
ecmascript@(guile-user)> $1['pointer->procedure'] ($1['double'], $3, $8);
$9 = #<procedure 2a5fa20 (_)>
ecmascript@(guile-user)> $9 (2);
$10 = 1.4142135623730951
--8<---------------cut here---------------end--------------->8---
A bit verbose, but funny. :-)
Ludo’.
[Prev in Thread] | Current Thread | [Next in Thread] |