# Beastie and Scheme

- Scheme

Resources:

- There is a collection of per-procedure documentation in the procedure list.
- Within the REPL, `(help foo)` will show brief documentation for the `foo` procedure.
- There are some examples in the directory `examples/`.

## Scheme

There are numerous introductions to Scheme; regarding reference material, the terse classic ‘R5RS’ is the mostly widely known and implemented standard, and ‘R7RS’ the most recent (s7 asserts compatibility with R5RS and R7RS). There is a short list of standards texts at the Scheme conservancy.

Ths Scheme here is that of s7, which is pretty standard, but with some eccentricities. This is a mini-scheme, intended as an extension language, and its source is entirely contained within the Beastie sources. The s7 manual has notes on the details and quirks of this implementation and its (very good!) FFI.

As a dialect (and Scheme has lots of dialects!), s7 is quite close to Guile, and the tutorial for that is therefore a good introduction to Beastie's scheme as well.

As well as the functions described here, Beastie/s7 has some additional peculiarities:

- `lambda` can be written `λ` (just because it looks nicer).

- We implement srfi-62 comments, thus the form `#;(foo ...)`, if found in the input, is ignored

- We also (mostly) implement Julia-like strings: `#"""foo bar"""` will be parsed as a possibly multi-line string (Julia triple-quote strings are like Python ones, but they always dedent by removing the shortest common whitespace prefix). The only deficiency in the implementation is that Julia strings can be continued with a trailing backslash, and ours can't be.

- Beastie includes ‘normal’ Scheme strings `"..."`, of course, but adds to these ‘Unicode-strings’, written `#"..."`, which have Unicode-specific operations defined on them. See the Unicode module for details.

- Function `(printf "fmt" args...)` will format and print to stdout, and `eprintf` and `sprintf` will do the same to stderr and a string (yes, these are just wrappers for the usual `format` procedure).

- We implement a basic module system for built-in modules. The form `(module 'bibtex)`, for example, will load the definitions which are probably helpful for working with BibTeX files. These modules are documented together. This is in addition to s7's support for loading.

- See also the collection of core functions which extend the basic s7 runtime.

I am not 100% committed to the implementation in s7. As a Scheme, s7 does have its little foibles, which occasionally grate, but which are compensated for by s7 being very easy to work with and extend. It is possible (though, I should concede, unlikely) that the balance of the various considerations may change in future, enough that I might enjoy the amusement of reimplementing this in a different Scheme.

Norman
2026 August 02