Inline::MzScheme - Inline module for the PLT MzScheme interpreter
This document describes version 0.05 of Inline::MzScheme, released June 13, 2004.
use subs 'perl_multiply'; # have to declare before Inline runs use Math::BigInt; use Inline MzScheme => q{ (define (square x) (perl-multiply x x)) (define assoc-list '((1 . 2) (3 . 4) (5 . 6))) (define linked-list '(1 2 3 4 5 6)) (define hex-string (bigint 'as_hex)) }, (bigint => Math::BigInt->new(1792)); sub perl_multiply { $_[0] * $_[1] } print square(10); # 100 print $hex_string; # 0x700 print $assoc_list->{1}; # 2 print $linked_list->[3]; # 4
This module allows you to add blocks of Scheme code to your Perl scripts and modules.
All user-defined procedures in your Scheme code will be available as Perl subroutines; association lists and hash tables are available as Perl hash refereces; lists and vectors available as array references; boxed values become scalar references.
Perl subroutines in the same package are imported as Scheme primitives, as long as they are declared before the use Inline MzScheme line.
use Inline MzScheme
Non-word characters in Scheme identifiers are turned into _ for Perl. Underscores in Perl identifiers are turned into - for Scheme.
_
-
Additional objects, classes and procedures may be imported into Scheme, by passing them as config parameters to use Inline. See Inline for details about this syntax.
use Inline
You can invoke perl objects in Scheme code with the syntax:
(object 'method arg1 arg2 ...)
If your method takes named argument lists, this will do:
(object 'method 'key1 val1 'key2 val2)
For information about handling MzScheme data in Perl, please see Language::MzScheme. This module is mostly a wrapper around Language::MzScheme::scheme_eval_string with a little auto-binding magic for procedures and input variables.
Thanks to Sam Tregar's Inline::Guile for showing me how to do this.
Language::MzScheme, Inline
Autrijus Tang <autrijus@autrijus.org>
Copyright 2004 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install Inline::MzScheme, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Inline::MzScheme
CPAN shell
perl -MCPAN -e shell install Inline::MzScheme
For more information on module installation, please visit the detailed CPAN module installation guide.