Where it is right now:
use Inline::Guile;
my $g = Inline::Guile.new;
say $g.run_i('(+ 3 7)'); # 10
say $g.run_s('"boo"'); # 'boo'
Where it will go soon:
say $g.run('(+ 3 7)');
say $g.run('"boo"');
After Slang::Guile has been written:
use Slang::Guile;
guile-sub car( $x ) { car $x }
guile-sub cdr( $x ) { cdr $x }
use Test;
is car <a b c>, 'a';
is-deeply [ cdr <a b c> ], ['b', 'c'];
I've already figured out how to write the helper code for most of this. Writing the C glue code at compile time using Perl 6 will let me share constants between C, Guile and Perl 6. Two problems I can foresee with this are that strings will need to be surrounded with dynwind-protect so that they don't leak from the Guile interpreter, and I don't think the NativeCall array types support arbitrarily-recursive arrays, I.E. CArray
Int is just a flat array of entries.
I can solve this by passing back a typed array of int32s like so:
(3 "a" (7 9) "after") =>
( INTEGER, 3, STRING, "a", START-LIST, Nil, INTEGER, 7, INTEGER, 9, EN
+D-LIST, Nil, STRING, "after" )
so that everything is returned in a homogeneous data structure, and it's up to the Perl 6 layer to unswizzle this back to:
is-deeply \$g.run(q{'(3 "a" (7 9) "after")}),
[ 3, "a", [ 7, 9 ], "after" ];
Hopefully I'll have time around FOSDEM to put this all together.