Where it will go soon:use Inline::Guile; my $g = Inline::Guile.new; say $g.run_i('(+ 3 7)'); # 10 say $g.run_s('"boo"'); # 'boo'
After Slang::Guile has been written:say $g.run('(+ 3 7)'); say $g.run('"boo"');
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. CArrayInt is just a flat array of entries. I can solve this by passing back a typed array of int32s like so: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'];
so that everything is returned in a homogeneous data structure, and it's up to the Perl 6 layer to unswizzle this back to:(3 "a" (7 9) "after") => ( INTEGER, 3, STRING, "a", START-LIST, Nil, INTEGER, 7, INTEGER, 9, EN +D-LIST, Nil, STRING, "after" )
Hopefully I'll have time around FOSDEM to put this all together.is-deeply \$g.run(q{'(3 "a" (7 9) "after")}), [ 3, "a", [ 7, 9 ], "after" ];
In reply to Introducing Scheme In Perl 6 by DrForr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |