guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guile status. Some questions to adopt usage as embedded game.


From: Ludovic Courtès
Subject: Re: Guile status. Some questions to adopt usage as embedded game.
Date: Tue, 25 Mar 2014 22:13:25 +0100
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

address@hidden (Ludovic Courtès) skribis:

> Germán Diago <address@hidden> skribis:

[...]

>> 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>.

Here’s a session that uses the FFI from ECMAscript to bind the C
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’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]