[PRL] ANN: Larceny v0.95 "First Safety"

William D Clinger will at ccs.neu.edu
Thu Nov 8 15:41:29 EST 2007


In private email, which I quote with his permission, sam th wrote:

> Since one of the new features of Larceny seems to be compatibility
> with a standard by the name of ERR5RS, which hasn't previously been
> mentioned on PRL, perhaps you should send something to the list about
> it.  I would appreciate hearing about it.

The main entry point to the ERR5RS wiki is
http://scheme-punks.org/wiki/index.php?title=ERR5RS:Charter

ERR5RS is very much a work still in progress, but the most
important wiki pages at the ERR5RS site are being translated
into SRFIs.  Whether ERR5RS becomes a full-scale revision
of the R5RS document, as was done by the R6RS process, will
depend in part upon the response to those SRFIs.

The text below is extracted from Larceny's doc/HOWTO-ERR5RS
file.  You might also be interested in reading Larceny's
doc/HOWTO-R6RS file, whose initial structure is somewhat
parallel; Larceny's download pages link to both.

Will

--------

ABOUT ERR5RS

ERR5RS is an expeditious revision of the R5RS to fill part
of the gap that lies between the R5RS and R6RS [1,2,3].
ERR5RS extends the R5RS by adding

  * R6RS-compatible library and import syntax
  * dynamic loading of libraries
  * dynamic importing of libraries
  * repl-friendly semantics for top-level programs
  * a subset of R6RS lexical syntax
  * R6RS-compatible records, but with superior APIs

The most important thing to know about ERR5RS is that it is
a supplement to the R6RS, not a replacement.  ERR5RS makes
the most important innovations of the R6RS available for use
in read/eval-print loops and R5RS-style dynamic programs,
which are outside the scope of the R6RS.

The second most important thing to know about ERR5RS is that
it is being designed with portability in mind.  Its statement
of requirements and goals mentions several different aspects
of portability:

  * portability/reuse between R5RS and ERR5RS (backward compatibility)
  * portability/reuse between different implementations of ERR5RS
  * portability/reuse between ERR5RS and R6RS programs
  * ease of understanding
  * ease of implementation

ERR5RS libraries are portable because the mapping between
library names and files is not left up to implementations,
but is specified by the extended semantics of loading and
importing.

Portability of ERR5RS libraries and programs also depends
upon the availability and quality of ERR5RS-compatible
implementations.  Larceny v0.95 was the first implementation
of ERR5RS, and Larceny's users have a great opportunity to
influence the continuing evolution and acceptance of ERR5RS.


ERR5RS MODE

To interact with Larceny's ERR5RS read/eval/print loop,
specify the -err5rs option on Larceny's command line:

    % larceny -err5rs
    Larceny v0.95 "First Safety" (...)
    ERR5RS mode (no libraries have been imported)

Since no libraries have been imported, the only forms you
can evaluate are constant literals, variable references
(but no variables have been imported!), procedure calls
(but no procedure values are accessible!), library
definitions, and import forms.  The first thing you'll
want to do is to import some of the pre-loaded libraries,
such as:

    > (import (rnrs base) (rnrs lists) (rnrs io simple))

Once you have imported (rnrs base) or a composite library
that includes it, you can evaluate definitions and use
all other syntax and variables you have imported:

    > (define two^7 (expt 2 (+ 3 4)))
    > two^7
    128


DYNAMIC LOADING

To load libraries, top-level programs, or unadorned
R5RS-style code from a file, you must first import a
suitable load procedure:

    > (import (err5rs load))

Loading a library does not automatically import it:

    > (load "lib/R6RS/benchmarking.sch")
    > (time (vector-for-each + (make-vector 1000000 0)))

    Error: Undefined global variable "time".
    Entering debugger; type "?" for help.
    debug> q

To use the variables and syntax that are exported by a
library, you must first load and then import that library
explicitly:

    > (import (larceny benchmarking))
    > (time (vector-for-each + (make-vector 1000000 0)))
    Words allocated: 3095752
    Words reclaimed: 0
    Elapsed time...: 111 ms (User: 104 ms; System: 8 ms)
    Elapsed GC time: 4 ms (CPU: 4 in 8 collections.)

Before you import a library or load a top-level program,
you must first load all of the nonstandard libraries it
imports.

You do not have to import those libraries into the ERR5RS
top level, however, unless you want to use the variables
and syntax exported by those libraries in the expressions
and definitions you evaluate at the top level.


PRE-LOADED LIBRARIES

For your convenience, Larceny pre-loads all of the standard
R6RS libraries and several other libraries besides, so you
can import from those libraries without having to load them
yourself.  The pre-loaded libraries include:

  R6RS standard libraries:

    (rnrs base (6))                  ; R6RS chapter 9
    (rnrs unicode (6))               ; R6RS library chapter 1
    (rnrs bytevectors (6))           ; R6RS library chapter 2
    (rnrs lists (6))                 ; R6RS library chapter 3
    (rnrs sorting (6))               ; R6RS library chapter 4
    (rnrs control (6))               ; R6RS library chapter 5
    (rnrs exceptions (6))            ; R6RS library section 7.1
    (rnrs conditions (6))            ; R6RS library sections 7.2 and 7.3
    (rnrs io ports (6))              ; R6RS library sections 8.1 and 8.2
    (rnrs io simple (6))             ; R6RS library sections 8.1 and 8.3
    (rnrs files (6))                 ; R6RS library chapter 9
    (rnrs programs (6))              ; R6RS library chapter 10
    (rnrs arithmetic fixnums (6))    ; R6RS library section 11.2
    (rnrs arithmetic flonums (6))    ; R6RS library section 11.3
    (rnrs arithmetic bitwise (6))    ; R6RS library section 11.4
    (rnrs syntax-case (6))           ; R6RS library chapter 12
    (rnrs hashtables (6))            ; R6RS library chapter 13
    (rnrs enums)                     ; R6RS library chapter 14
    (rnrs (6))                       ; R6RS library chapter 15
    (rnrs eval (6))                  ; R6RS library chapter 16
    (rnrs mutable-pairs (6))         ; R6RS library chapter 17
    (rnrs mutable-strings (6))       ; R6RS library chapter 18
    (rnrs r5rs (6))                  ; R6RS library chapter 19

  R6RS standard libraries that are pre-loaded but deprecated in Larceny:

    (rnrs records procedural (6))    ; R6RS library section 6.3 (deprecated)
    (rnrs records inspection (6))    ; R6RS library section 6.4 (deprecated)
    (rnrs records syntactic)         ; R6RS library section 6.2 (deprecated)

  Other pre-loaded libraries:

    (err5rs records procedural)      ; ERR5RS records (procedural API)
    (err5rs records inspection)      ; ERR5RS records (inspection API)
    (err5rs records syntactic)       ; ERR5RS records (syntactic API)
    (err5rs load)                    ; ERR5RS load procedure
    (rnrs load)                      ; equivalent to (err5rs load)
    (r5rs)                           ; approximates the R5RS top level
    (explicit-renaming)              ; a macro system with explicit renaming


--------

[1] http://scheme-punks.org/wiki/index.php?title=ERR5RS:Charter
[2] http://www.schemers.org/Documents/Standards/R5RS/
[3] http://www.r6rs.org/



More information about the PRL mailing list