Running a top-level R6RS program under PLT Racket
With the setup described in my previous post on Larceny, I could find no way to run the same top-level program under PLT Racket. That language processor requires all libraries to be contained in “collections,” i.e., directories.
Accordingly, I created a subdirectory called greeting, moved greeting.sls into it, and revised the import clause of the top-level greeter to read
(import (greeting greeting))
I also revised the library name at the beginning of greeting.sls to read
(greeting greeting (0 0))
In both cases, the idea was to identify the contents of the greeting.sls file as a library called greeting within a collection also called greeting.
I discovered that, because of the diversity of language variants that the PLT Racket processor accepts and distinguishes, R6RS library modules must begin with the comment
#!r6rs
in order to be recognized.
With these changes, I found that the command
plt-r6rs ++path . top-level-greeter.ss
executed the program.
I confirmed that the Larceny and Ikarus Scheme command lines that I worked out continued to work under the new arrangement of files:
ikarus --r6rs-script top-level-greeter.ss larceny -r6rs -path . -program top-level-greeter.ss
Running a top-level R6RS program under Ikarus Scheme
With the setup described in my previous post on Larceny, I was able to run the same top-level program under Ikarus Scheme with the shell command
ikarus --r6rs-script top-level-greeter.ss
Ikarus Scheme presupposes that the names of the libraries are relative to the current working directory.
Running a top-level R6RS program under Larceny
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.