CMUCL User's Manual
Total Page:16
File Type:pdf, Size:1020Kb
CMUCL User's Manual December 2018 21d Robert A. MacLachlan, Editor cmucl is a free, high-performance implementation of the Common Lisp programming language, which runs on most major Unix platforms. It mainly conforms to the ANSI Common Lisp Standard. cmucl features a sophisticated native-code compiler, a for- eign function interface, a graphical source-level debugger, an interface to the X11 Win- dow System, and an Emacs-like editor. Keywords: lisp, Common Lisp, manual, compiler, programming language implementa- tion, programming environment This manual is based on CMU Technical Report CMU-CS-92-161, edited by Robert A. MacLachlan, dated July 1992. i Table of Contents 1 Introduction::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.1 Distribution and Support :::::::::::::::::::::::::::::::::::::::::::::: 1 1.2 Command Line Options ::::::::::::::::::::::::::::::::::::::::::::::: 1 1.3 Credits:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2 Design Choices and Extensions :::::::::::::::::::::::::::: 6 2.1 Data Types ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 6 2.1.1 Integers :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 6 2.1.2 Floats:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 6 2.1.2.1 IEEE Special Values :::::::::::::::::::::::::::::::::::::::: 6 2.1.2.2 Negative Zero ::::::::::::::::::::::::::::::::::::::::::::::: 7 2.1.2.3 Denormalized Floats :::::::::::::::::::::::::::::::::::::::: 7 2.1.2.4 Floating Point Exceptions ::::::::::::::::::::::::::::::::::: 7 2.1.2.5 Floating Point Rounding Mode :::::::::::::::::::::::::::::: 7 2.1.2.6 Accessing the Floating Point Modes ::::::::::::::::::::::::: 8 2.1.3 Extended Floats ::::::::::::::::::::::::::::::::::::::::::::::::: 9 2.1.4 Characters :::::::::::::::::::::::::::::::::::::::::::::::::::::: 10 2.1.5 Array Initialization:::::::::::::::::::::::::::::::::::::::::::::: 10 2.1.6 Hash tables ::::::::::::::::::::::::::::::::::::::::::::::::::::: 10 2.2 Default Interrupts for Lisp ::::::::::::::::::::::::::::::::::::::::::: 11 2.3 Implementation-Specific Packages::::::::::::::::::::::::::::::::::::: 12 2.4 Hierarchical Packages :::::::::::::::::::::::::::::::::::::::::::::::: 13 2.4.1 Introduction :::::::::::::::::::::::::::::::::::::::::::::::::::: 13 2.4.2 Relative Package Names::::::::::::::::::::::::::::::::::::::::: 13 2.4.3 Compatibility with ANSI Common Lisp ::::::::::::::::::::::::: 14 2.4.3.1 Changes to cl:find-package :::::::::::::::::::::::::::::: 14 2.4.3.2 Using Hierarchical Packages without Modifying cl:find-package ::::::::::::::::::::::::::::: 15 2.5 Package Locks ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 15 2.5.1 Rationale ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 15 2.5.2 Disabling package locks ::::::::::::::::::::::::::::::::::::::::: 16 2.6 The Editor ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 17 2.7 Garbage Collection ::::::::::::::::::::::::::::::::::::::::::::::::::: 17 2.7.1 GC Parameters ::::::::::::::::::::::::::::::::::::::::::::::::: 17 2.7.2 Generational GC :::::::::::::::::::::::::::::::::::::::::::::::: 18 2.7.3 Weak Pointers :::::::::::::::::::::::::::::::::::::::::::::::::: 19 2.7.4 Finalization ::::::::::::::::::::::::::::::::::::::::::::::::::::: 19 2.8 Describe ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 20 2.9 The Inspector :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 20 2.9.1 The Graphical Interface ::::::::::::::::::::::::::::::::::::::::: 20 2.9.2 The TTY Inspector ::::::::::::::::::::::::::::::::::::::::::::: 21 2.10 Load:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 21 2.11 The Reader ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 22 2.11.1 Reader Extensions ::::::::::::::::::::::::::::::::::::::::::::: 22 2.11.2 Reader Parameters::::::::::::::::::::::::::::::::::::::::::::: 22 2.12 Stream Extensions :::::::::::::::::::::::::::::::::::::::::::::::::: 22 2.13 Simple Streams ::::::::::::::::::::::::::::::::::::::::::::::::::::: 23 ii 2.14 Running Programs from Lisp :::::::::::::::::::::::::::::::::::::::: 23 2.14.1 Process Accessors :::::::::::::::::::::::::::::::::::::::::::::: 25 2.15 Saving a Core Image :::::::::::::::::::::::::::::::::::::::::::::::: 26 2.16 Pathnames:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 27 2.16.1 Unix Pathnames ::::::::::::::::::::::::::::::::::::::::::::::: 27 2.16.2 Wildcard Pathnames ::::::::::::::::::::::::::::::::::::::::::: 28 2.16.3 Logical Pathnames ::::::::::::::::::::::::::::::::::::::::::::: 28 2.16.4 Search Lists:::::::::::::::::::::::::::::::::::::::::::::::::::: 28 2.16.5 Predefined Search-Lists :::::::::::::::::::::::::::::::::::::::: 29 2.16.6 Search-List Operations ::::::::::::::::::::::::::::::::::::::::: 29 2.16.7 Search List Example ::::::::::::::::::::::::::::::::::::::::::: 30 2.17 Filesystem Operations::::::::::::::::::::::::::::::::::::::::::::::: 30 2.17.1 Wildcard Matching :::::::::::::::::::::::::::::::::::::::::::: 30 2.17.2 File Name Completion ::::::::::::::::::::::::::::::::::::::::: 30 2.17.3 Miscellaneous Filesystem Operations ::::::::::::::::::::::::::: 31 2.18 Time Parsing and Formatting ::::::::::::::::::::::::::::::::::::::: 31 2.19 Random Number Generation :::::::::::::::::::::::::::::::::::::::: 33 2.19.1 MT-19937 Generator ::::::::::::::::::::::::::::::::::::::::::: 33 2.19.2 xoroshiro128+ Generator::::::::::::::::::::::::::::::::::::::: 33 2.20 Lisp Threads:::::::::::::::::::::::::::::::::::::::::::::::::::::::: 33 2.21 Lisp Library :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 33 2.22 Generalized Function Names :::::::::::::::::::::::::::::::::::::::: 34 2.23 CLOS::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 34 2.23.1 Primary Method Errors :::::::::::::::::::::::::::::::::::::::: 34 2.23.2 Slot Type Checking :::::::::::::::::::::::::::::::::::::::::::: 34 2.23.3 Slot Access Optimization::::::::::::::::::::::::::::::::::::::: 35 2.23.3.1 slot-boundp Declaration ::::::::::::::::::::::::::::::::: 35 2.23.3.2 inline Declaration ::::::::::::::::::::::::::::::::::::::: 35 2.23.3.3 Automatic Method Recompilation::::::::::::::::::::::::: 36 2.23.4 Inlining Methods in Effective Methods:::::::::::::::::::::::::: 37 2.23.5 Effective Method Precomputation :::::::::::::::::::::::::::::: 38 2.23.6 Sealing :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 38 2.23.7 Method Tracing and Profiling :::::::::::::::::::::::::::::::::: 38 2.23.8 Misc ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 39 2.24 Differences from ANSI Common Lisp :::::::::::::::::::::::::::::::: 39 2.24.1 Extensions ::::::::::::::::::::::::::::::::::::::::::::::::::::: 39 2.25 Function Wrappers:::::::::::::::::::::::::::::::::::::::::::::::::: 39 2.26 Dynamic-Extent Declarations ::::::::::::::::::::::::::::::::::::::: 41 2.26.1 &rest argument lists ::::::::::::::::::::::::::::::::::::::::::: 41 2.26.2 Closures ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 42 2.26.3 list, list*, and cons ::::::::::::::::::::::::::::::::::::::::: 42 2.27 Modular Arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::: 42 2.28 Extension to REQUIRE::::::::::::::::::::::::::::::::::::::::::::: 43 2.29 Localization::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 43 2.29.1 Dictionary ::::::::::::::::::::::::::::::::::::::::::::::::::::: 43 2.29.2 Example Usage :::::::::::::::::::::::::::::::::::::::::::::::: 45 2.30 Static Arrays ::::::::::::::::::::::::::::::::::::::::::::::::::::::: 46 iii 3 The Debugger:::::::::::::::::::::::::::::::::::::::::::::: 48 3.1 Debugger Introduction ::::::::::::::::::::::::::::::::::::::::::::::: 48 3.2 The Command Loop ::::::::::::::::::::::::::::::::::::::::::::::::: 48 3.3 Stack Frames::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 49 3.3.1 Stack Motion ::::::::::::::::::::::::::::::::::::::::::::::::::: 49 3.3.2 How Arguments are Printed ::::::::::::::::::::::::::::::::::::: 49 3.3.3 Function Names::::::::::::::::::::::::::::::::::::::::::::::::: 50 3.3.4 Funny Frames::::::::::::::::::::::::::::::::::::::::::::::::::: 50 3.3.5 Debug Tail Recursion ::::::::::::::::::::::::::::::::::::::::::: 51 3.3.6 Unknown Locations and Interrupts :::::::::::::::::::::::::::::: 51 3.4 Variable Access :::::::::::::::::::::::::::::::::::::::::::::::::::::: 52 3.4.1 Variable Value Availability :::::::::::::::::::::::::::::::::::::: 52 3.4.2 Note On Lexical Variable Access :::::::::::::::::::::::::::::::: 53 3.5 Source Location Printing ::::::::::::::::::::::::::::::::::::::::::::: 53 3.5.1 How the Source is Found :::::::::::::::::::::::::::::::::::::::: 54 3.5.2 Source Location Availability::::::::::::::::::::::::::::::::::::: 55 3.6 Compiler Policy Control:::::::::::::::::::::::::::::::::::::::::::::: 55 3.7 Exiting Commands::::::::::::::::::::::::::::::::::::::::::::::::::: 56 3.8 Information Commands :::::::::::::::::::::::::::::::::::::::::::::: 56 3.9 Breakpoint Commands ::::::::::::::::::::::::::::::::::::::::::::::: 57 3.9.1 Breakpoint Example :::::::::::::::::::::::::::::::::::::::::::: 57 3.10 Function Tracing:::::::::::::::::::::::::::::::::::::::::::::::::::: 59 3.10.1 Encapsulation Functions ::::::::::::::::::::::::::::::::::::::: 61 3.10.2 Tracing Examples :::::::::::::::::::::::::::::::::::::::::::::: 61 3.11 Specials ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 62 4 The Compiler :::::::::::::::::::::::::::::::::::::::::::::: 63 4.1 Compiler Introduction:::::::::::::::::::::::::::::::::::::::::::::::: 63 4.2 Calling the Compiler