Integration of libscheme and Tcl (announce)

Kathi Fisler (kfisler@cs.indiana.edu)
Mon, 3 Oct 1994 10:16:03 -0500

I was told that someone suggested integrating libscheme and Tcl during
the recent Tcl discussion. I announced such an integration on
comp.lang.tcl last spring. Here is the README file from the
distribution, including instructions for how to obtain the package.

ABOUT Schemepkg

Schemepkg is a Tcl/Tk package that provides an interface to a scheme
interpreter from within Tcl scripts. Unlike Stk, Schemepkg is not a
scheme interpreter for Tk; it is merely a set of Tcl commands that can
be used to evaluate scheme code from within Tcl scripts. The creation
of the package was inspired by the author's desire to use scheme code
with interfaces built using XF. This package is based on Brent
Benson's Libscheme, which is a C library implementing a Scheme
interpreter. Libscheme is required in order to use Schemepkg.

GETTING Schemepkg

Schemepkg may be obtained via ftp at ftp.cs.indiana.edu/pub/kfisler.
It is available in both .Z and .gz formats.

GETTING Libscheme

Libscheme may be obtained via ftp from the Scheme Repository at
Indiana University in ftp.cs.indiana.edu/pub/scheme-repository/imp, or
via the Web at ftp://ftp.cs.indiana.edu/pub/scheme-repository/imp.
Schemepkg has been tested with Libscheme version 0.3. For special
instructions on how to compile Libscheme so that it is compatible with
Schemepkg, see INSTALL.

USING Schemepkg

Installation instructions for Schemepkg are provided in INSTALL. The
package provides two new Tcl commands, with the following syntax:

scheme "s-exp" (alternatively, scheme {s-exp})

scheme_source filename

The first command passes s-exp to the Scheme interpreter and returns a
string containing the result of the evaluation. In keeping with Tcl's
use of strings, the interface with Scheme is completely string based.
The differences between using quotes versus brackets for passing an
s-exp to Scheme are as determined by the Tcl syntax. If the "s-exp"
form is used, Tcl variable and command substitutions will be performed
in "s-exp" before it is passed to the Scheme interpreter. For
example, the code

set x 4
scheme "(+ $x 5)"

will return a string containing 9. However, if the {s-exp} is used,
s-exp will be passed to the Scheme interpreter without substitutions.

Flat lists may be shared between scheme and Tcl as demonstrated in the
following example. There may be ways to support the sharing of nested
lists, but I have not yet figured out the interface syntax
(suggestions are welcome).

set x {2 3 4 5}
set y [scheme "(cons 1 '([join $x]))"]

==> 1 2 3 4 5

The second command, scheme_source, is the analog of the Tcl source
command (equivalent to load in scheme). The argument file must
contain pure scheme code, not Tcl scheme commands.

The Scheme_Init procedure provided with this package initializes the
scheme interpreter with an empty global environment. At present, all
s-exps passed to the scheme command are evaluated in this single
environment and the environment is maintained between calls to the
Scheme interpreter. This environment is distinct from the Tcl
environment; any communication between the two environments must be
coded explicitly by the user. At present, there is no support for
multiple environments.

FILES INCLUDED IN THIS DISTRIBUTION

COPYING
INSTALL
Makefile
README

schemepkg.ss scheme procedure for creating return value string
schemepkg.c command procedure and Scheme_Init definitions
schemepkg.h
tclSchemeAppInit.c App file for Tcl interpreter extended with Scheme
commands
tkSchemeAppInit.c App file for wish interpreter extended with Scheme
commands

format.scm These two files are needed for the creation of the
pp.scm return value string. They have been taken from
the scheme repository at Indiana University.

Libscheme-Extras/

Makefile scheme_str_rd.c extends Libscheme to allow for
scheme_str_rd.c reading from strings as opposed to from stdin.
Makefile is a copy of the original Libscheme
makefile, augmented with the compilation and
linking of scheme_str_rd.

AUTHORS

Schemepkg was written by Kathi Fisler (kfisler@cs.indiana.edu).
Shriram Krishnamurthi wrote the code for scheme_str_rd. Libscheme was
written by Brent Benson. Author information for format.scm and pp.scm
is provided in the respective files. Bug reports and suggestions
should be sent to the above address.

-- 
Kathi Fisler                                    kfisler@cs.indiana.edu

Visual Inference and Hardware Methods Laboratories, Indiana University