The Guile Reference Manual
This manual documents Guile version 3.0.11.
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation, Inc.
Copyright (C) 2021 Maxime Devos
Copyright (C) 2024 Tomas Volf
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.”
Additionally, the documentation of the SRFI 64 module is adapted from its specification text, which is made available under the following Expat license:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Additionally, the documentation of the SRFI 197 module is adapted from its specification text, which is made available under the following MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Table of Contents
- 3.4.1 Names, Locations, Values and Environments
- 3.4.2 Local Variables and Environments
- 3.4.3 Environment Chaining
- 3.4.4 Lexical Scope
- 3.4.5 Closure
- 3.4.6 Example 1: A Serial Number Generator
- 3.4.7 Example 2: A Shared Persistent Variable
- 3.4.8 Example 3: The Callback Closure Problem
- 3.4.9 Example 4: Object Orientation
5.7 An Overview of Guile Programming
5.7.1 How One Might Extend Dia Using Guile
- 5.7.1.1 Deciding Why You Want to Add Guile
- 5.7.1.2 Four Steps Required to Add Guile
- 5.7.1.3 How to Represent Dia Data in Scheme
- 5.7.1.4 Writing Guile Primitives for Dia
- 5.7.1.5 Providing a Hook for the Evaluation of Scheme Code
- 5.7.1.6 Top-level Structure of Guile-enabled Dia
- 5.7.1.7 Going Further with Dia and Guile
- 6.6.2.1 Scheme’s Numerical “Tower”
- 6.6.2.2 Integers
- 6.6.2.3 Real and Rational Numbers
- 6.6.2.4 Complex Numbers
- 6.6.2.5 Exact and Inexact Numbers
- 6.6.2.6 Read Syntax for Numerical Data
- 6.6.2.7 Operations on Integer Values
- 6.6.2.8 Comparison Predicates
- 6.6.2.9 Converting Numbers To and From Strings
- 6.6.2.10 Complex Number Operations
- 6.6.2.11 Arithmetic Functions
- 6.6.2.12 Scientific Functions
- 6.6.2.13 Bitwise Operations
- 6.6.2.14 Random Number Generation
- 6.6.5.1 String Read Syntax
- 6.6.5.2 String Predicates
- 6.6.5.3 String Constructors
- 6.6.5.4 List/String conversion
- 6.6.5.5 String Selection
- 6.6.5.6 String Modification
- 6.6.5.7 String Comparison
- 6.6.5.8 String Searching
- 6.6.5.9 Alphabetic Case Mapping
- 6.6.5.10 Reversing and Appending Strings
- 6.6.5.11 Mapping, Folding, and Unfolding
- 6.6.5.12 Miscellaneous String Operations
- 6.6.5.13 Representing Strings as Bytes
- 6.6.5.14 Conversion to/from C
- 6.6.5.15 String Internals
- 6.6.12.1 Endianness
- 6.6.12.2 Manipulating Bytevectors
- 6.6.12.3 Interpreting Bytevector Contents as Integers
- 6.6.12.4 Converting Bytevectors to/from Integer Lists
- 6.6.12.5 Interpreting Bytevector Contents as Floating Point Numbers
- 6.6.12.6 Interpreting Bytevector Contents as Unicode Strings
- 6.6.12.7 Accessing Bytevectors with the Array API
- 6.6.12.8 Accessing Bytevectors with the SRFI-4 API
- 6.6.12.9 Bytevector Procedures in R7RS
- 6.6.12.10 Bytevector Slices
6.11 Controlling the Flow of Program Execution
6.16 Reading and Evaluating Scheme Code
- 6.18.1 General Information about Modules
- 6.18.2 Using Guile Modules
- 6.18.3 Creating Guile Modules
- 6.18.4 Modules and the File System
- 6.18.5 R6RS Version References
- 6.18.6 R6RS Libraries
- 6.18.7 Variables
- 6.18.8 Module System Reflection
- 6.18.9 Declarative Modules
- 6.18.10 Accessing Modules from C
- 6.18.11 provide and require
- 6.18.12 Environments
7.2 POSIX System Calls and Networking
7.3 HTTP, the Web, and All That
- 7.6.2.1 Library Usage
- 7.6.2.2 rnrs base
- 7.6.2.3 rnrs unicode
- 7.6.2.4 rnrs bytevectors
- 7.6.2.5 rnrs lists
- 7.6.2.6 rnrs sorting
- 7.6.2.7 rnrs control
- 7.6.2.8 R6RS Records
- 7.6.2.9 rnrs records syntactic
- 7.6.2.10 rnrs records procedural
- 7.6.2.11 rnrs records inspection
- 7.6.2.12 rnrs exceptions
- 7.6.2.13 rnrs conditions
- 7.6.2.14 I/O Conditions
- 7.6.2.15 Transcoders
- 7.6.2.16 rnrs io ports
- 7.6.2.17 R6RS File Ports
- 7.6.2.18 rnrs io simple
- 7.6.2.19 rnrs files
- 7.6.2.20 rnrs programs
- 7.6.2.21 rnrs arithmetic fixnums
- 7.6.2.22 rnrs arithmetic flonums
- 7.6.2.23 rnrs arithmetic bitwise
- 7.6.2.24 rnrs syntax-case
- 7.6.2.25 rnrs hashtables
- 7.6.2.26 rnrs enums
- 7.6.2.27 rnrs
- 7.6.2.28 rnrs eval
- 7.6.2.29 rnrs mutable-pairs
- 7.6.2.30 rnrs mutable-strings
- 7.6.2.31 rnrs r5rs
8.6 Methods and Generic Functions
- 8.11.1 Metaobjects and the Metaobject Protocol
- 8.11.2 Metaclasses
- 8.11.3 MOP Specification
- 8.11.4 Instance Creation Protocol
- 8.11.5 Class Definition Protocol
- 8.11.6 Customizing Class Definition
- 8.11.7 Method Definition
- 8.11.8 Method Definition Internals
- 8.11.9 Generic Function Internals
- 8.11.10 Generic Function Invocation
9.3 A Virtual Machine for Guile
- 9.3.7.1 Call and Return Instructions
- 9.3.7.2 Function Prologue Instructions
- 9.3.7.3 Shuffling Instructions
- 9.3.7.4 Trampoline Instructions
- 9.3.7.5 Non-Local Control Flow Instructions
- 9.3.7.6 Instrumentation Instructions
- 9.3.7.7 Intrinsic Call Instructions
- 9.3.7.8 Constant Instructions
- 9.3.7.9 Memory Access Instructions
- 9.3.7.10 Atomic Memory Access Instructions
- 9.3.7.11 Tagging and Untagging Instructions
- 9.3.7.12 Integer Arithmetic Instructions
- 9.3.7.13 Floating-Point Arithmetic Instructions
- 9.3.7.14 Comparison Instructions
- 9.3.7.15 Branch Instructions
- 9.3.7.16 Raw Memory Access Instructions