in reply to Re^3: Introducing Scheme In Perl 6
in thread Introducing Scheme In Perl 6

The facts that (a) it's not in the Perl 6 ecosystem, (b) it's not version 1.0 yet, (c) I haven't even added support for lists yet (need to talk to nine) and (d) I stated that it wasn't ready, should make it pretty clear that this isn't a finished product, I'm sorry if I gave that impression.

Also, if you read the full posting I'm fully intending to create a Slang::Scheme::Guile that will actually embed the language inside Perl 6 to the point of being able to write:

use Slang::Scheme::Guile; guile-sub add( $x, $y ) { + $x $y }

Passing in variables marshalled in from another language is trivial, and clearly documented as scm_call_*, with list creation clearly documented as scm_list_*. There is an entire section devoted to a tutorial on how to create your own custom procedures and even entire object types that you can invoke from within Scheme. In fact, with a little bit of work it might be possible to let the Slang user create their own classes and export them as Scheme objects.

In fact, the time I'm taking to write this response is longer than it would take to create a sample Scheme function written in C, creating the Perl callback would take a little longer. I don't have the documentation to hand as I'm outside my development VM here, but a sample C function that exposes a color attribute from Lilypond (one of the programs that hosts a Guile interpreter) to Scheme is roughly 10 lines of code, including marshalling the 24-bit alpha mask from Lilypond's internal format to Scheme.

Also, please remember that Guile Scheme is designed to be an embedded language. Look at the Wikipedia page to see how many applications, including GNU Make, are using it as an embedded language. This is one of the reasons I chose this Scheme implementation to embed, rather than say, SIOD or some other library.

Lastly, if you'll read the Guile Scheme documentation, you'll see two whole sections devoted to letting Guile Scheme access the host application, including a lengthy tutorial on creating custom Guile Scheme types customized for your application.

If you think it's easier to (1) write a new Scheme on top of MoarVM, (2) modify the Perl 6 runtime to allow a whole new language in parallel with the existing Perl 6 binary, (3) write a new ICE-9 function library on top of your new Scheme implementation in order to call back to Perl, (4) not go completely mad writing call-with-current-continuation to unwind a stack from Scheme to Perl 6 across two interpreter threads, and (5) do this all in the time it'll take me to add an ICE-9-Perl6 function library, you're more than welcome to take on the challenge, and I doff my hat to you.