So far, so good. Nothing tricky about installing Chez Scheme.

When navigating through previous expressions, only the first line of a multi-line expression is shown. To see (and edit) all lines, type CTRL + L . In the middle of an expression, RET creates a new line; to enter an expression from the middle of an expression, use CTRL + J .

To launch the Chez REPL on macOS, open Terminal and type chez . On Windows, four Chez programs were installed (32- or 64-bit threaded and unthreaded). Open any of those programs to get a Chez REPL.

Library Directory

Chez does not come with a package manager, but there are 3rd-party options, e.g., Akku. In this post, though, I will describe manual package management.

library-directories returns the directories where Chez looks for libraries.

> (library-directories) (("." . "."))

The "." indicates that Chez is looking in the current directory. . If you are using a project-based workflow, then you could include your dependencies in the current directory, perhaps in a lib folder. For a ‘global’ approach, I created a library directory at /Users/username/scheme/lib on macOS, and at C:\scheme\lib on Windows.

Before we go over where to stash that directory information, let’s cover library extensions.

> (library-extensions) ((".chezscheme.sls" . ".chezscheme.so") (".ss" . ".so") (".sls" . ".so") (".scm" . ".so") (".sch" . ".so"))

These are the file extensions that Chez uses when searching the library directories.

On macOS , you edit .bash_profile to add information on library directories and extensions. From a Terminal window, open .bash_profile with the Nano text editor.

$ nano .bash_profile

These lines add a new directory to library-directories and a new extension to library-extensions .

export CHEZSCHEMELIBDIRS="/Users/username/scheme/lib:" export CHEZSCHEMELIBEXTS=".sc::.so:"

The : at the end is used to indicate that the new entries should be appended to the existing entries. Remove the : to replace the default values with the new entries. After saving .bash_profile , enter the following command in the Terminal.

$ source .bash_profile

Now, from a Chez REPL, we can see the effect of our changes.

> (library-directories) (("/Users/username/scheme/lib" . "/Users/username/scheme/lib") ("." . ".")) > (library-extensions) ((".sc" . ".so") (".chezscheme.sls" . ".chezscheme.so") (".ss" . ".so") (".sls" . ".so") (".scm" . ".so") (".sch" . ".so"))

If we have a library at /Users/username/scheme/lib/srfi/s1/lists.sls , then we import the library with (import (srfi s1 lists)) , i.e., you pass the components of the path to import. If you can’t import the library, look at the library call at the top of lists.sls , for example, because that will give you a clue of where the library expects to be placed in library-directories .

> (xcons 1 2) Exception: variable xcons is not bound Type (debug) to enter the debugger. > (import (srfi s1 lists)) > (xcons 1 2) (2 . 1)