Aubrey Jaffer This Manual Is for SCM (Version 5F3, February 2020), an Implementation of the Algorithmic Language Scheme
Total Page:16
File Type:pdf, Size:1020Kb
SCM Scheme Implementation Version 5f3 Aubrey Jaffer This manual is for SCM (version 5f3, February 2020), an implementation of the algorithmic language Scheme. Copyright c 1990-2007 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License." i Table of Contents 1 Overview ::::::::::::::::::::::::::::::::::::::::: 1 1.1 Features :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.2 Authors :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.3 Copyright :::::::::::::::::::::::::::::::::::::::::::::::::::::: 2 1.3.1 The SCM License :::::::::::::::::::::::::::::::::::::::::: 2 1.3.2 SIOD copyright :::::::::::::::::::::::::::::::::::::::::::: 2 1.3.3 GNU Free Documentation License ::::::::::::::::::::::::: 3 1.4 Bibliography :::::::::::::::::::::::::::::::::::::::::::::::::: 10 2 Installing SCM ::::::::::::::::::::::::::::::::: 12 2.1 Distributions :::::::::::::::::::::::::::::::::::::::::::::::::: 12 2.2 GNU configure and make :::::::::::::::::::::::::::::::::::::: 12 2.2.1 Making scmlit :::::::::::::::::::::::::::::::::::::::::::: 13 2.2.2 Makefile targets :::::::::::::::::::::::::::::::::::::::::: 14 2.3 Building SCM ::::::::::::::::::::::::::::::::::::::::::::::::: 15 2.3.1 Invoking Build:::::::::::::::::::::::::::::::::::::::::::: 15 2.3.2 Build Options :::::::::::::::::::::::::::::::::::::::::::: 17 2.3.3 Compiling and Linking Custom Files:::::::::::::::::::::: 22 2.4 Saving Executable Images ::::::::::::::::::::::::::::::::::::: 23 2.5 Installation :::::::::::::::::::::::::::::::::::::::::::::::::::: 24 2.6 Troubleshooting and Testing ::::::::::::::::::::::::::::::::::: 24 2.6.1 Problems Compiling :::::::::::::::::::::::::::::::::::::: 24 2.6.2 Problems Linking ::::::::::::::::::::::::::::::::::::::::: 25 2.6.3 Testing ::::::::::::::::::::::::::::::::::::::::::::::::::: 25 2.6.4 Problems Starting :::::::::::::::::::::::::::::::::::::::: 26 2.6.5 Problems Running :::::::::::::::::::::::::::::::::::::::: 26 2.6.6 Reporting Problems :::::::::::::::::::::::::::::::::::::: 27 3 Operational Features::::::::::::::::::::::::::: 28 3.1 Invoking SCM ::::::::::::::::::::::::::::::::::::::::::::::::: 28 3.2 Options ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 28 3.3 Invocation Examples :::::::::::::::::::::::::::::::::::::::::: 30 3.4 Environment Variables :::::::::::::::::::::::::::::::::::::::: 31 3.5 Scheme Variables :::::::::::::::::::::::::::::::::::::::::::::: 31 3.6 SCM Session :::::::::::::::::::::::::::::::::::::::::::::::::: 31 3.7 Editing Scheme Code :::::::::::::::::::::::::::::::::::::::::: 32 3.8 Debugging Scheme Code::::::::::::::::::::::::::::::::::::::: 33 3.9 Debugging Continuations :::::::::::::::::::::::::::::::::::::: 35 3.10 Errors:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 36 3.11 Memoized Expressions:::::::::::::::::::::::::::::::::::::::: 38 3.12 Internal State :::::::::::::::::::::::::::::::::::::::::::::::: 39 3.12.1 Executable path ::::::::::::::::::::::::::::::::::::::::: 40 ii 3.13 Scripting ::::::::::::::::::::::::::::::::::::::::::::::::::::: 41 3.13.1 Unix Scheme Scripts::::::::::::::::::::::::::::::::::::: 41 3.13.2 MS-DOS Compatible Scripts::::::::::::::::::::::::::::: 42 3.13.3 Unix Shell Scripts ::::::::::::::::::::::::::::::::::::::: 43 4 The Language :::::::::::::::::::::::::::::::::: 44 4.1 Standards Compliance ::::::::::::::::::::::::::::::::::::::::: 44 4.2 Storage:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 46 4.3 Time :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 46 4.4 Interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::::: 47 4.5 Process Synchronization ::::::::::::::::::::::::::::::::::::::: 48 4.6 Files and Ports :::::::::::::::::::::::::::::::::::::::::::::::: 49 4.6.1 Opening and Closing ::::::::::::::::::::::::::::::::::::: 49 4.6.2 Port Properties ::::::::::::::::::::::::::::::::::::::::::: 50 4.6.3 Port Redirection :::::::::::::::::::::::::::::::::::::::::: 51 4.6.4 Soft Ports :::::::::::::::::::::::::::::::::::::::::::::::: 52 4.7 Eval and Load::::::::::::::::::::::::::::::::::::::::::::::::: 52 4.7.1 Line Numbers :::::::::::::::::::::::::::::::::::::::::::: 53 4.8 Lexical Conventions ::::::::::::::::::::::::::::::::::::::::::: 54 4.8.1 Common-Lisp Read Syntax ::::::::::::::::::::::::::::::: 54 4.8.2 Load Syntax:::::::::::::::::::::::::::::::::::::::::::::: 55 4.8.3 Documentation and Comments ::::::::::::::::::::::::::: 55 4.8.4 Modifying Read Syntax ::::::::::::::::::::::::::::::::::: 56 4.9 Syntax :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 56 4.9.1 Define and Set:::::::::::::::::::::::::::::::::::::::::::: 56 4.9.2 Defmacro ::::::::::::::::::::::::::::::::::::::::::::::::: 58 4.9.3 Syntax-Rules ::::::::::::::::::::::::::::::::::::::::::::: 58 4.9.4 Macro Primitives ::::::::::::::::::::::::::::::::::::::::: 59 4.9.5 Environment Frames:::::::::::::::::::::::::::::::::::::: 60 4.9.6 Syntactic Hooks for Hygienic Macros:::::::::::::::::::::: 61 4.9.7 Use of Synthetic Identifiers ::::::::::::::::::::::::::::::: 62 5 Packages :::::::::::::::::::::::::::::::::::::::: 65 5.1 Dynamic Linking :::::::::::::::::::::::::::::::::::::::::::::: 65 5.2 Dump ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 66 5.3 Numeric::::::::::::::::::::::::::::::::::::::::::::::::::::::: 68 5.4 Arrays :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 69 5.4.1 Conventional Arrays :::::::::::::::::::::::::::::::::::::: 70 5.4.2 Uniform Array:::::::::::::::::::::::::::::::::::::::::::: 71 5.4.3 Bit Vectors ::::::::::::::::::::::::::::::::::::::::::::::: 72 5.4.4 Array Mapping ::::::::::::::::::::::::::::::::::::::::::: 73 5.5 Records ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 74 5.6 I/O-Extensions :::::::::::::::::::::::::::::::::::::::::::::::: 74 5.7 Posix Extensions :::::::::::::::::::::::::::::::::::::::::::::: 78 5.8 Unix Extensions ::::::::::::::::::::::::::::::::::::::::::::::: 82 5.9 Sequence Comparison ::::::::::::::::::::::::::::::::::::::::: 83 5.10 Regular Expression Pattern Matching::::::::::::::::::::::::: 83 iii 5.11 Line Editing:::::::::::::::::::::::::::::::::::::::::::::::::: 85 5.12 Curses ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 85 5.12.1 Output Options Setting ::::::::::::::::::::::::::::::::: 86 5.12.2 Terminal Mode Setting :::::::::::::::::::::::::::::::::: 86 5.12.3 Window Manipulation ::::::::::::::::::::::::::::::::::: 87 5.12.4 Output :::::::::::::::::::::::::::::::::::::::::::::::::: 89 5.12.5 Input:::::::::::::::::::::::::::::::::::::::::::::::::::: 90 5.12.6 Curses Miscellany ::::::::::::::::::::::::::::::::::::::: 90 5.13 Sockets::::::::::::::::::::::::::::::::::::::::::::::::::::::: 91 5.13.1 Host and Other Inquiries :::::::::::::::::::::::::::::::: 91 5.13.2 Internet Addresses and Socket Names :::::::::::::::::::: 92 5.13.3 Socket::::::::::::::::::::::::::::::::::::::::::::::::::: 93 5.14 SCMDB:::::::::::::::::::::::::::::::::::::::::::::::::::::: 96 5.15 Xlibscm :::::::::::::::::::::::::::::::::::::::::::::::::::::: 96 5.16 Hobbit ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 96 6 The Implementation ::::::::::::::::::::::::::: 97 6.1 Data Types ::::::::::::::::::::::::::::::::::::::::::::::::::: 97 6.1.1 Immediates ::::::::::::::::::::::::::::::::::::::::::::::: 97 6.1.2 Cells ::::::::::::::::::::::::::::::::::::::::::::::::::::: 99 6.1.3 Header Cells::::::::::::::::::::::::::::::::::::::::::::: 100 6.1.4 Subr Cells ::::::::::::::::::::::::::::::::::::::::::::::: 102 6.1.5 Defining Subrs::::::::::::::::::::::::::::::::::::::::::: 103 6.1.6 Ptob Cells::::::::::::::::::::::::::::::::::::::::::::::: 104 6.1.7 Defining Ptobs :::::::::::::::::::::::::::::::::::::::::: 105 6.1.8 Smob Cells :::::::::::::::::::::::::::::::::::::::::::::: 106 6.1.9 Defining Smobs:::::::::::::::::::::::::::::::::::::::::: 107 6.1.10 Data Type Representations ::::::::::::::::::::::::::::: 108 6.2 Operations ::::::::::::::::::::::::::::::::::::::::::::::::::: 110 6.2.1 Garbage Collection :::::::::::::::::::::::::::::::::::::: 110 6.2.1.1 Marking Cells :::::::::::::::::::::::::::::::::::::: 110 6.2.1.2 Sweeping the Heap ::::::::::::::::::::::::::::::::: 111 6.2.2 Memory Management for Environments:::::::::::::::::: 111 6.2.3 Dynamic Linking Support ::::::::::::::::::::::::::::::: 113 6.2.4 Configure Module Catalog ::::::::::::::::::::::::::::::: 113 6.2.5 Automatic C Preprocessor Definitions:::::::::::::::::::: 114 6.2.6 Signals :::::::::::::::::::::::::::::::::::::::::::::::::: 116 6.2.7 C Macros:::::::::::::::::::::::::::::::::::::::::::::::: 116 6.2.8 Changing Scm ::::::::::::::::::::::::::::::::::::::::::: 117 6.2.9 Allocating memory :::::::::::::::::::::::::::::::::::::: 119 6.2.10 Embedding SCM ::::::::::::::::::::::::::::::::::::::: 120 6.2.11 Callbacks :::::::::::::::::::::::::::::::::::::::::::::: 123 6.2.12 Type Conversions :::::::::::::::::::::::::::::::::::::: 124 6.2.13 Continuations :::::::::::::::::::::::::::::::::::::::::: 125 6.2.14 Evaluation ::::::::::::::::::::::::::::::::::::::::::::: 127 6.3 Program Self-Knowledge:::::::::::::::::::::::::::::::::::::: 128 6.3.1 File-System Habitat ::::::::::::::::::::::::::::::::::::: 128 6.3.2 Executable Pathname ::::::::::::::::::::::::::::::::::: 129 iv 6.3.3 Script Support