Algorithms for functional programming: the blog

News and behind-the-scenes details on AFP: the book
Posts tagged as larceny

Running a top-level R6RS program under Larceny

2011-08-16 by stone

One way in which I'll frequently be using the Scheme language processors that I've installed is to run a top-level Scheme program that imports libraries that I create as well as standard R6RS libraries. The mechanics of this process vary from one language processor to another. Indeed, the author of the Larceny user manual notes that “[t]he R6RS standard does not specify any way for a top-level program to define its own libraries.” As a result, R6RS language processors that permit this are obliged to extend the standard, so one would expect to find differences.

I created a directory called /home/stone/Projects/AFP/r6rs-testing and placed in it two files. One, greeting.sls, defines an R6RS library; apart from comments, it contains

  (library (greeting (0 0))
    (export hello)
    (import (rnrs base (6))
            (rnrs io simple (6)))

    (define hello
      (lambda ()
        (display "Hello, world!")
        (newline))))

The other file, top-level-greeter.ss, imports the greeting library and invokes its procedure:

  (import (greeting))

  (hello)

If the current working directory is the one containing these two files, the shell command

  larceny -r6rs -path . -program top-level-greeter.ss

runs the top-level greeter. The -path command-line option takes a colon-separated list of directories in which Larceny is to search for libraries.

Current R6RS implementations

2011-08-16 by stone

In developing and testing the algorithm implementations in Algorithms for functional programming, I propose to use Scheme language processors that implement the R6RS standard completely and correctly and are available as Debian packages, ideally packages that the Debian Project itself includes in the free stable distribution.

The list of R6RS implementations at http://www.r6rs.org/implementations.html identifies eight of them: Chez Scheme, Guile, Ikarus Scheme, IronScheme, Larceny, Mosh Scheme, PLT Racket, and Ypsilon.

A binary-only version of Chez Scheme (without the compiler) is available under an unfree license from the developer. The current version is 8.3.

Chez Scheme download site ... Chez Scheme version 8 user's guide ... The Scheme programming language, fourth edition

Guile is available as a Debian package (guile-1.8), but the version that Debian provides is older and does not implement R6RS. A newer version is available from the GNU Project as a tarball.

GNU Guile download site ... Guile reference manual (PDF version)

Ikarus Scheme is available as a Debian package (ikarus), but it is not a complete implementation of R6RS Scheme, and no one appears to be maintaining it. The developer's site (http://ikarus-scheme.org/) is currently out of service.

Ikarus Scheme user's guide

IronScheme is based on the Microsoft Dynamic Language Runtime and so cannot be expected to run in a GNU environment.

Larceny is available as a prebuilt binary for the Intel 32-bit architecture. The developer also provides source code, under the Lesser General Public License and an alternative license that appears to be unique to Larceny.

Larceny download site ... Larceny User Manual (PDF version)

Mosh Scheme is available as a tarball.

Mosh Scheme download site ... Mosh Scheme user manual

The Debian Project packages and distributes PLT Racket (version 5.1.1) for version squeeze in its squeeze-backports/main section. The package names are racket and racket-doc. If you already have the PLT Scheme packages installed, the Debian package manager will require you to remove them as you install PLT Racket.

Racket documentation

Ypsilon is available as a tarball (version 0.9.6.update3). There appears to be no useful documentation for it.

Ypsilon download site

I already had Ikarus Scheme on the desktop that I'll be working on this semester, and I installed the Debian packages for PLT Racket and the binaries for Larceny. For compatibility testing, I plan eventually to install Guile and Mosh Scheme as well.

Although it is possible to install Larceny in user space, I decided that it would be preferable to have set it up in /opt. As root on eunoia, I downloaded the tarball into /tmp and unpacked it into a new directory in /opt:

  cd /tmp
  /usr/bin/wget http://www.larcenists.org/LarcenyReleases/larceny-0.97-bin-native-ia32-linux86.tar.gz
  cd /opt
  /bin/tar xvzf /tmp/larceny-0.97-bin-native-ia32-linux86.tar.gz 

I then added the lines

  if [ -d /opt/larceny-0.97-bin-native-ia32-linux86 ]
  then
    PATH=$PATH:/opt/larceny-0.97-bin-native-ia32-linux86
  fi

to add Larceny's directory to the shell's search path.