The Incomplete Scheme 48 Reference Manual for release 1.9.2

#
Acknowledgements

Thanks to Scheme 48’s users for their suggestions, bug reports, and forbearance. Thanks also to Deborah Tatar for providing the Yeats quotation.

    Copyright � 1986-2001 Richard Kelsey and Jonathan Rees.
    Copyright � 1993-2001 Richard Kelsey.
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
    1. Redistributions of source code must retain the above copyright
       notices, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright
       notices, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
    3. The name of the authors may not be used to endorse or promote products
       derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
Contents

1 Introduction

2 User’s guide
2.1 Command line arguments
2.2 Command processor
2.3 Editing
2.4 Performance
2.5 Disassembler
2.6 Module system
2.7 Library

3 Command processor
3.1 Current focus value and `##`
3.2 Command levels
3.3 Logistical commands
3.4 Module commands
3.5 Debugging commands
3.6 Profiling commands
3.6.1 How the profiler works
3.7 Settings
3.8 Inspection mode
3.9 Command programs
3.10 Building images
3.11 Resource query and control
3.12 Threads
3.13 Quite obscure

4 Module system
4.1 Introduction
4.2 The configuration language
4.3 Interfaces
4.4 Macros
4.5 Higher-order modules
4.6 Compiling and linking
4.7 Semantics of configuration mutation
4.8 Command processor support
4.9 Configuration packages
4.10 Discussion

5 Libraries
5.1 General utilities
5.2 Pretty-printing
5.3 Bitwise integer operations
5.4 Byte vectors
5.5 Sparse vectors
5.6 Cells
5.7 Queues
5.8 Arrays
5.9 Records
5.9.1 Low-level access to records
5.9.2 Record types
5.10 Finite record types
5.11 Sets over finite types
5.12 Hash tables
5.13 Port extensions
5.14 Fluid bindings
5.15 OS strings
5.16 Shell commands
5.17 Sockets
5.18 Profiling
5.19 Macros for writing loops
5.19.1 `Iterate`
5.19.2 `Reduce`
5.19.3 Sequence types
5.19.4 Synchronous sequences
5.19.5 Examples
5.19.6 Defining sequence types
5.19.7 Expanded code
5.20 Sorting lists and vectors
5.20.1 Design rules
What vs. how
Consistency across procedure signatures
Less-than parameter first, data parameter after
Ordering, comparison procedures and stability
All vector operations accept optional subrange parameters
Required vs. allowed side-effects
5.20.2 Procedure specification
Procedure naming and functionality
Types of parameters and return values
5.20.2.1 `sorting`---general sorting package
5.20.2.2 Algorithm-specific sorting packages
`sorted`---sorted predicates
`list-merge-sort`---list merge sort
`vector-merge-sort`---vector merge sort
`vector-heap-sort`---vector heap sort
`vector-quick-sort`---vector quick sort
`vector-quick-sort3`---vector quick sort with 3-way comparisons
`vector-insert-sort`---vector insertion sort
`delete-neighbor-duplicates`---list and vector delete neighbor duplicates
`binary-searches`---vector binary search
5.20.3 Algorithmic properties
5.21 Regular expressions
5.21.1 Character sets
5.21.2 Anchoring
5.21.3 Composite expressions
5.21.4 Case sensitivity
5.21.5 Submatches and matching
5.22 SRFIs

6 Unicode
6.1 Characters and their codes
6.2 Character and string literals
6.2.1 Character literals
6.2.2 String literals
6.2.3 Identifiers and symbol literals
6.3 Character classification and case mappings
6.4 SRFI 14
6.5 R6RS
6.6 I/O
6.6.1 Text codecs
6.6.2 Text-codec utilities
6.6.3 Creating text codecs
6.7 Default encodings

7 Threads
7.1 Creating and controlling threads
7.2 Advanced thread handling
7.3 Debugging multithreaded programs
7.4 Optimistic concurrency
7.5 Condition variables
7.6 Mutual exclusion
7.6.1 Locks
7.6.2 Placeholders
7.7 Writing custom synchronization abstractions
7.8 Concurrent ML abstractions
7.8.1 Basic rendezvous combinators
7.8.2 Synchronous channels
7.8.3 Synchronous variables
7.8.3.1 Placeholders
7.8.3.2 Jars
7.8.4 Timeouts
7.8.5 CML to Scheme correspondence

8 Mixing Scheme 48 and C
8.1 Available facilities
8.1.1 Scheme structures
8.1.2 C naming conventions
8.1.3 Garbage collection and reference objects
8.2 Shared bindings
8.2.1 Exporting Scheme values to C
8.2.2 Exporting C values to Scheme
8.2.3 Complete shared binding interface
8.3 Calling C functions from Scheme
8.4 Dynamic loading
8.5 Accessing Scheme data from C
8.5.1 Constants
8.5.2 Converting values
8.5.3 C versions of Scheme procedures
8.6 Calling Scheme functions from C
8.7 Interacting with the Scheme heap
8.7.1 Registering global references
8.7.2 Local buffers
8.7.3 Special treatment for byte vectors
8.7.4 Memory overhead
8.7.5 Keeping C data structures in the Scheme heap
8.7.6 C code and heap images
8.8 Using Scheme records in C code
8.9 Raising exceptions from external code
8.10 External events
8.10.1 Collecting external events in external code
8.10.2 Handling external events in Scheme
8.11 Unsafe functions and macros
8.12 Converting external code to the new foreign-function interface

9 Access to POSIX
9.1 Process primitives
9.1.1 Process creation and termination
9.1.2 `Exec`
9.2 Signals
9.2.1 POSIX signals
9.2.2 Other signals
9.2.3 Sending signals
9.2.4 Receiving signals
9.3 Process environment
9.3.1 Process identification
9.3.2 Environment variables
9.4 Users and groups
9.5 OS and machine identification
9.6 Files and directories
9.6.1 Directory streams
9.6.2 Working directory
9.6.3 File creation and removal
9.6.4 File information
9.6.5 File modes
9.6.6 Symbolic links
9.7 Time and Date
9.7.1 Time
9.7.2 Date
9.8 I/O
9.9 Regular expressions
9.10 Syslog facility
9.11 Error codes
9.11.1 POSIX errnos
9.12 C to Scheme correspondence

Bibliography