This reference manual documents Guile, GNU’s Ubiquitous Intelligent Language for Extensions. It describes how to use Guile in many useful and interesting ways.
This is edition 1.1 of the reference manual, and corresponds to Guile version 1.8.6.
Table of Contents
1. Preface
1.1 Layout of this Manual
1.2 Conventions used in this Manual
1.3 Contributors to this Manual
1.4 The Guile License
2. Introduction to Guile
2.1 What is Guile?
2.2 Obtaining and Installing Guile
2.3 A Whirlwind Tour
2.3.1 Running Guile Interactively
2.3.2 Running Guile Scripts
2.3.3 Linking Guile into Programs
2.3.4 Writing Guile Extensions
2.3.5 Using the Guile Module System
2.3.5.1 Using Modules
2.3.5.2 Writing new Modules
2.3.5.3 Putting Extensions into Modules
2.4 Discouraged and Deprecated
2.5 Reporting Bugs
3. Programming in Scheme
3.1 Basic Ideas in Scheme
3.1.1 Data Types, Values and Variables
3.1.1.1 Latent Typing
3.1.1.2 Values and Variables
3.1.1.3 Defining and Setting Variables
3.1.2 The Representation and Use of Procedures
3.1.2.1 Procedures as Values
3.1.2.2 Simple Procedure Invocation
3.1.2.3 Creating and Using a New Procedure
3.1.2.4 Lambda Alternatives
3.1.3 Expressions and Evaluation
3.1.3.1 Evaluating Expressions and Executing Programs
3.1.3.2 Tail calls
3.1.3.3 Using the Guile REPL
3.1.3.4 Summary of Common Syntax
3.1.4 The Concept of Closure
3.1.4.1 Names, Locations, Values and Environments
3.1.4.2 Local Variables and Environments
3.1.4.3 Environment Chaining
3.1.4.4 Lexical Scope
3.1.4.5 Closure
3.1.4.6 Example 1: A Serial Number Generator
3.1.4.7 Example 2: A Shared Persistent Variable
3.1.4.8 Example 3: The Callback Closure Problem
3.1.4.9 Example 4: Object Orientation
3.2 Guile’s Implementation of Scheme
3.3 Guile Scripting
3.3.1 The Top of a Script File
3.3.2 Invoking Guile
3.3.3 The Meta Switch
3.3.4 Command Line Handling
3.3.5 Scripting Examples
3.4 Using Guile Interactively
3.4.1 Readline
3.4.2 Value History
3.4.3 Error Handling
3.4.4 Using the Interactive Debugger
3.4.4.1 Display Backtrace
3.4.4.2 Frame Selection
3.4.4.3 Frame Information
3.4.4.4 Frame Evaluation
3.4.4.5 Single Stepping and Continuing Execution
3.5 Using Guile in Emacs
3.5.1 GDS Introduction
3.5.2 GDS Architecture
3.5.3 Getting Started with GDS
3.5.3.1 Invoking GDS when an Exception Occurs
3.5.3.2 Accepting GDS Instructions at Any Time
3.5.3.3 Utility Guile Implementation
3.5.4 Working with GDS in Scheme Buffers
3.5.4.1 Access to Guile Help and Completion
3.5.4.2 Evaluating Scheme Code
3.5.5 Displaying the Scheme Stack
3.5.6 Continuing Execution
3.5.7 Associating Buffers with Clients
3.5.8 An Example GDS Session
3.6 Further Reading
4. Programming in C
4.1 Linking Programs With Guile
4.1.1 Guile Initialization Functions
4.1.2 A Sample Guile Main Program
4.2 Linking Guile with Libraries
4.2.1 A Sample Guile Extension
4.3 General concepts for using libguile
4.3.1 Dynamic Types
4.3.2 Garbage Collection
4.3.3 Control Flow
4.3.4 Asynchronous Signals
4.3.5 Multi-Threading
4.4 Defining New Types (Smobs)
4.4.1 Describing a New Type
4.4.2 Creating Instances
4.4.3 Type checking
4.4.4 Garbage Collecting Smobs
4.4.5 Garbage Collecting Simple Smobs
4.4.6 Remembering During Operations
4.4.7 Double Smobs
4.4.8 The Complete Example
4.5 Function Snarfing
4.6 An Overview of Guile Programming
4.6.1 How One Might Extend Dia Using Guile
4.6.1.1 Deciding Why You Want to Add Guile
4.6.1.2 Four Steps Required to Add Guile
4.6.1.3 How to Represent Dia Data in Scheme
4.6.1.4 Writing Guile Primitives for Dia
4.6.1.5 Providing a Hook for the Evaluation of Scheme Code
4.6.1.6 Top-level Structure of Guile-enabled Dia
4.6.1.7 Going Further with Dia and Guile
4.6.2 Why Scheme is More Hackable Than C
4.6.3 Example: Using Guile for an Application Testbed
4.6.4 A Choice of Programming Options
4.6.4.1 What Functionality is Already Available?
4.6.4.2 Functional and Performance Constraints
4.6.4.3 Your Preferred Programming Style
4.6.4.4 What Controls Program Execution?
4.6.5 How About Application Users?
5. API Reference
5.1 Overview of the Guile API
5.2 The SCM Type
5.3 Initializing Guile
5.4 Snarfing Macros
5.5 Simple Generic Data Types
5.5.1 Booleans
5.5.2 Numerical data types
5.5.2.1 Scheme’s Numerical “Tower”
5.5.2.2 Integers
5.5.2.3 Real and Rational Numbers
5.5.2.4 Complex Numbers
5.5.2.5 Exact and Inexact Numbers
5.5.2.6 Read Syntax for Numerical Data
5.5.2.7 Operations on Integer Values
5.5.2.8 Comparison Predicates
5.5.2.9 Converting Numbers To and From Strings
5.5.2.10 Complex Number Operations
5.5.2.11 Arithmetic Functions
5.5.2.12 Scientific Functions
5.5.2.13 Primitive Numeric Functions
5.5.2.14 Bitwise Operations
5.5.2.15 Random Number Generation
5.5.3 Characters
5.5.4 Character Sets
5.5.4.1 Character Set Predicates/Comparison
5.5.4.2 Iterating Over Character Sets
5.5.4.3 Creating Character Sets
5.5.4.4 Querying Character Sets
5.5.4.5 Character-Set Algebra
5.5.4.6 Standard Character Sets
5.5.5 Strings
5.5.5.1 String Read Syntax
5.5.5.2 String Predicates
5.5.5.3 String Constructors
5.5.5.4 List/String conversion
5.5.5.5 String Selection
5.5.5.6 String Modification
5.5.5.7 String Comparison
5.5.5.8 String Searching
5.5.5.9 Alphabetic Case Mapping
5.5.5.10 Reversing and Appending Strings
5.5.5.11 Mapping, Folding, and Unfolding
5.5.5.12 Miscellaneous String Operations
5.5.5.13 Conversion to/from C
5.5.6 Regular Expressions
5.5.6.1 Regexp Functions
5.5.6.2 Match Structures
5.5.6.3 Backslash Escapes
5.5.7 Symbols
5.5.7.1 Symbols as Discrete Data
5.5.7.2 Symbols as Lookup Keys
5.5.7.3 Symbols as Denoting Variables
5.5.7.4 Operations Related to Symbols
5.5.7.5 Function Slots and Property Lists
5.5.7.6 Extended Read Syntax for Symbols
5.5.7.7 Uninterned Symbols
5.5.8 Keywords
5.5.8.1 Why Use Keywords?
5.5.8.2 Coding With Keywords
5.5.8.3 Keyword Read Syntax
5.5.8.4 Keyword Procedures
5.5.9 “Functionality-Centric” Data Types
5.6 Compound Data Types
5.6.1 Pairs
5.6.2 Lists
5.6.2.1 List Read Syntax
5.6.2.2 List Predicates
5.6.2.3 List Constructors
5.6.2.4 List Selection
5.6.2.5 Append and Reverse
5.6.2.6 List Modification
5.6.2.7 List Searching
5.6.2.8 List Mapping
5.6.3 Vectors
5.6.3.1 Read Syntax for Vectors
5.6.3.2 Dynamic Vector Creation and Validation
5.6.3.3 Accessing and Modifying Vector Contents
5.6.3.4 Vector Accessing from C
5.6.4 Uniform Numeric Vectors
5.6.5 Bit Vectors
5.6.6 Generalized Vectors
5.6.7 Arrays
5.6.7.1 Array Syntax
5.6.7.2 Array Procedures
5.6.7.3 Shared Arrays
5.6.7.4 Accessing Arrays from C
5.6.8 Records
5.6.9 Structures
5.6.9.1 Vtables
5.6.9.2 Structure Basics
5.6.9.3 Vtable Contents
5.6.9.4 Vtable Vtables
5.6.10 Dictionary Types
5.6.11 Association Lists
5.6.11.1 Alist Key Equality
5.6.11.2 Adding or Setting Alist Entries
5.6.11.3 Retrieving Alist Entries
5.6.11.4 Removing Alist Entries
5.6.11.5 Sloppy Alist Functions
5.6.11.6 Alist Example
5.6.12 Hash Tables
5.6.12.1 Hash Table Examples
5.6.12.2 Hash Table Reference
5.7 Smobs
5.8 Procedures and Macros
5.8.1 Lambda: Basic Procedure Creation
5.8.2 Primitive Procedures
5.8.3 Optional Arguments
5.8.3.1 let-optional Reference
5.8.3.2 let-keywords Reference
5.8.3.3 lambda* Reference
5.8.3.4 define* Reference
5.8.4 Procedure Properties and Meta-information
5.8.5 Procedures with Setters
5.8.6 Lisp Style Macro Definitions
5.8.7 The R5RS syntax-rules System
5.8.7.1 The syntax-rules Pattern Language
5.8.7.2 Top Level Syntax Definitions
5.8.7.3 Local Syntax Definitions
5.8.8 Support for the syntax-case System
5.8.9 Internal Representation of Macros and Syntax
5.9 General Utility Functions
5.9.1 Equality
5.9.2 Object Properties
5.9.2.1 Low Level Property Implementation.
5.9.2.2 An Older Approach to Properties
5.9.3 Sorting
5.9.4 Copying Deep Structures
5.9.5 General String Conversion
5.9.6 Hooks
5.9.6.1 Hook Usage by Example
5.9.6.2 Hook Reference
5.9.6.3 Handling Scheme-level hooks from C code
5.9.6.4 Hooks For C Code.
5.9.6.5 Hooks for Garbage Collection
5.9.6.6 Hooks into the Guile REPL
5.10 Definitions and Variable Bindings
5.10.1 Top Level Variable Definitions
5.10.2 Local Variable Bindings
5.10.3 Internal definitions
5.10.4 Querying variable bindings
5.11 Controlling the Flow of Program Execution
5.11.1 Evaluating a Sequence of Expressions
5.11.2 Simple Conditional Evaluation
5.11.3 Conditional Evaluation of a Sequence of Expressions
5.11.4 Iteration mechanisms
5.11.5 Continuations
5.11.6 Returning and Accepting Multiple Values
5.11.7 Exceptions
5.11.7.1 Exception Terminology
5.11.7.2 Catching Exceptions
5.11.7.3 Throw Handlers
5.11.7.4 Catch Without Unwinding
5.11.7.5 Throwing Exceptions
5.11.7.6 How Guile Implements Exceptions
5.11.8 Procedures for Signaling Errors
5.11.9 Dynamic Wind
5.11.10 How to Handle Errors
5.11.10.1 C Support
5.12 Input and Output
5.12.1 Ports
5.12.2 Reading
5.12.3 Writing
5.12.4 Closing
5.12.5 Random Access
5.12.6 Line Oriented and Delimited Text
5.12.7 Block reading and writing
5.12.8 Default Ports for Input, Output and Errors
5.12.9 Types of Port
5.12.9.1 File Ports
5.12.9.2 String Ports
5.12.9.3 Soft Ports
5.12.9.4 Void Ports
5.12.10 Using and Extending Ports in C
5.12.10.1 C Port Interface
5.12.10.2 Port Implementation
5.13 Reading and Evaluating Scheme Code
5.13.1 Scheme Syntax: Standard and Guile Extensions
5.13.1.1 Expression Syntax
5.13.1.2 Comments
5.13.1.3 Block Comments
5.13.1.4 Case Sensitivity
5.13.1.5 Keyword Syntax
5.13.1.6 Reader Extensions
5.13.2 Reading Scheme Code
5.13.3 Procedures for On the Fly Evaluation
5.13.4 Loading Scheme Code from File
5.13.5 Delayed Evaluation
5.13.6 Local Evaluation
5.13.7 Evaluator Behaviour
5.14 Memory Management and Garbage Collection
5.14.1 Function related to Garbage Collection
5.14.2 Memory Blocks
5.14.2.1 Upgrading from scm_must_malloc et al.
5.14.3 Weak References
5.14.3.1 Weak hash tables
5.14.3.2 Weak vectors
5.14.4 Guardians
5.15 Objects
5.16 Modules
5.16.1 provide and require
5.16.2 Environments
5.16.3 The Guile module system
5.16.3.1 General Information about Modules
5.16.3.2 Using Guile Modules
5.16.3.3 Creating Guile Modules
5.16.3.4 Module System Reflection
5.16.3.5 Module System Quirks
5.16.3.6 Included Guile Modules
5.16.3.7 Accessing Modules from C
5.16.4 Dynamic Libraries
5.16.4.1 Low level dynamic linking
5.16.4.2 Putting Compiled Code into Modules
5.16.4.3 Dynamic Linking and Compiled Code Modules
5.16.4.4 Compiled Code Installation
5.16.5 Variables
5.17 Threads, Mutexes, Asyncs and Dynamic Roots
5.17.1 Arbiters
5.17.2 Asyncs
5.17.2.1 System asyncs
5.17.2.2 User asyncs
5.17.3 Continuation Barriers
5.17.4 Threads
5.17.5 Mutexes and Condition Variables
5.17.6 Blocking in Guile Mode
5.17.7 Critical Sections
5.17.8 Fluids and Dynamic States
5.17.9 Parallel forms
5.18 Configuration, Features and Runtime Options
5.18.1 Configuration, Build and Installation
5.18.2 Feature Tracking
5.18.2.1 Feature Manipulation
5.18.2.2 Common Feature Symbols
5.18.3 Runtime Options
5.18.3.1 Low Level Options Interfaces
5.18.3.2 User Level Options Interfaces
5.18.3.3 Reader options
5.18.3.4 Printing options
5.18.3.5 Evaluator options
5.18.3.6 Evaluator trap options
5.18.3.7 Debugger options
5.18.3.8 Examples of option use
5.19 Support for Translating Other Languages
5.19.1 Emacs Lisp Support
5.20 Support for Internationalization
5.21 Debugging Infrastructure
5.21.1 Evaluation and the Scheme Stack
5.21.1.1 Capturing the Stack or Innermost Stack Frame
5.21.1.2 Examining the Stack
5.21.1.3 Examining Stack Frames
5.21.1.4 Source Properties
5.21.1.5 Decoding Memoized Source Expressions
5.21.1.6 Starting a New Stack
5.21.2 Debugging when an error occurs
5.21.2.1 Intercepting basic error information
5.21.2.2 Capturing the full error stack
5.21.2.3 Displaying or interrogating the captured stack
5.21.2.4 What the Guile REPL does
5.21.3 Traps
5.21.3.1 A Quick Note on Terminology
5.21.3.2 How to Set a Trap
5.21.3.3 Specifying Trap Behaviour
5.21.3.4 Trap Context
5.21.3.5 Tracing Examples
5.21.3.6 Tracing Configuration
5.21.3.7 Tracing and (ice-9 debug)
5.21.3.8 Traps Installing More Traps
5.21.3.9 Common Trap Options
5.21.3.10 Procedure Traps
5.21.3.11 Exit Traps
5.21.3.12 Entry Traps
5.21.3.13 Apply Traps
5.21.3.14 Step Traps
5.21.3.15 Source Traps
5.21.3.16 Location Traps
5.21.3.17 Trap Shorthands
5.21.3.18 Trap Utilities
5.21.4 Debugging Examples
5.21.4.1 Single Stepping through a Procedure’s Code
5.21.4.2 Profiling or Tracing a Procedure’s Code
5.22 GH: A Portable C to Scheme Interface
5.22.1 Why the GH Interface is Now Deprecated
5.22.2 Transitioning away from GH
5.22.3 GH preliminaries
5.22.4 Data types and constants defined by GH
5.22.5 Starting and controlling the interpreter
5.22.6 Error messages
5.22.7 Executing Scheme code
5.22.8 Defining new Scheme procedures in C
5.22.9 Converting data between C and Scheme
5.22.9.1 C to Scheme
5.22.9.2 Scheme to C
5.22.10 Type predicates
5.22.11 Equality predicates
5.22.12 Memory allocation and garbage collection
5.22.13 Calling Scheme procedures from C
6. Guile Modules
6.1 SLIB
6.1.1 SLIB installation
6.1.2 JACAL
6.2 POSIX System Calls and Networking
6.2.1 POSIX Interface Conventions
6.2.2 Ports and File Descriptors
6.2.3 File System
6.2.4 User Information
6.2.5 Time
6.2.6 Runtime Environment
6.2.7 Processes
6.2.8 Signals
6.2.9 Terminals and Ptys
6.2.10 Pipes
6.2.11 Networking
6.2.11.1 Network Address Conversion
6.2.11.2 Network Databases
6.2.11.3 Network Socket Address
6.2.11.4 Network Sockets and Communication
6.2.11.5 Network Socket Examples
6.2.12 System Identification
6.2.13 Locales
6.2.14 Encryption
6.3 The (ice-9 getopt-long) Module
6.3.1 A Short getopt-long Example
6.3.2 How to Write an Option Specification
6.3.3 Expected Command Line Format
6.3.4 Reference Documentation for getopt-long
6.3.5 Reference Documentation for option-ref
6.4 SRFI Support Modules
6.4.1 About SRFI Usage
6.4.2 SRFI-0 - cond-expand
6.4.3 SRFI-1 - List library
6.4.3.1 Constructors
6.4.3.2 Predicates
6.4.3.3 Selectors
6.4.3.4 Length, Append, Concatenate, etc.
6.4.3.5 Fold, Unfold & Map
6.4.3.6 Filtering and Partitioning
6.4.3.7 Searching
6.4.3.8 Deleting
6.4.3.9 Association Lists
6.4.3.10 Set Operations on Lists
6.4.4 SRFI-2 - and-let*
6.4.5 SRFI-4 - Homogeneous numeric vector datatypes
6.4.6 SRFI-6 - Basic String Ports
6.4.7 SRFI-8 - receive
6.4.8 SRFI-9 - define-record-type
6.4.9 SRFI-10 - Hash-Comma Reader Extension
6.4.10 SRFI-11 - let-values
6.4.11 SRFI-13 - String Library
6.4.12 SRFI-14 - Character-set Library
6.4.13 SRFI-16 - case-lambda
6.4.14 SRFI-17 - Generalized set!
6.4.15 SRFI-19 - Time/Date Library
6.4.15.1 SRFI-19 Introduction
6.4.15.2 SRFI-19 Time
6.4.15.3 SRFI-19 Date
6.4.15.4 SRFI-19 Time/Date conversions
6.4.15.5 SRFI-19 Date to string
6.4.15.6 SRFI-19 String to date
6.4.16 SRFI-26 - specializing parameters
6.4.17 SRFI-31 - A special form ‘rec’ for recursive evaluation
6.4.18 SRFI-34 - Exception handling for programs
6.4.19 SRFI-35 - Conditions
6.4.20 SRFI-37 - args-fold
6.4.21 SRFI-39 - Parameters
6.4.22 SRFI-55 - Requiring Features
6.4.23 SRFI-60 - Integers as Bits
6.4.24 SRFI-61 - A more general cond clause
6.4.25 SRFI-69 - Basic hash tables
6.4.25.1 Creating hash tables
6.4.25.2 Accessing table items
6.5 Readline Support
6.5.1 Loading Readline Support
6.5.2 Readline Options
6.5.3 Readline Functions
6.5.3.1 Readline Port
6.5.3.2 Completion
6.6 Value History
6.7 Pretty Printing
6.8 Formatted Output
6.9 File Tree Walk
6.10 Queues
6.11 Streams
6.12 Buffered Input
6.13 Expect
6.14 The Scheme shell (scsh)
6.15 Tracing
7. Autoconf Support
7.1 Autoconf Background
7.2 Autoconf Macros
7.3 Using Autoconf Macros
7.4 Autofrisk
7.5 Using Autofrisk
Appendix A Data Representation in Guile
A.1 Data Representation in Scheme
A.1.1 A Simple Representation
A.1.2 Faster Integers
A.1.3 Cheaper Pairs
A.1.4 Guile Is Hairier
A.2 How Guile does it
A.2.1 General Rules
A.2.2 Conservative Garbage Collection
A.2.3 Immediates vs Non-immediates
A.2.4 Immediate Datatypes
A.2.4.1 Integers
A.2.4.2 Characters
A.2.4.3 Booleans
A.2.4.4 Unique Values
A.2.5 Non-immediate Datatypes
A.2.5.1 Pairs
A.2.5.2 Vectors, Strings, and Symbols
A.2.5.3 Procedures
A.2.5.4 Closures
A.2.5.5 Subrs
A.2.5.6 Ports
A.2.6 Signalling Type Errors
A.2.7 Unpacking the SCM Type
A.2.7.1 Relationship between SCM and scm_t_bits
A.2.7.2 Immediate objects
A.2.7.3 Non-immediate objects
A.2.7.4 Allocating Cells
A.2.7.5 Heap Cell Type Information
A.2.7.6 Accessing Cell Entries
A.2.7.7 Basic Rules for Accessing Cell Entries
Appendix B GNU Free Documentation License
B.0.1 ADDENDUM: How to use this License for your documents
Indices
Objectives & Topics
This reference manual serves as a comprehensive guide to Guile, which is GNU's ubiquitous intelligent language for extensions. The document aims to explain how to use Guile in a variety of environments, ranging from an interactive command-line interpreter to a library embedded within C/C++ applications, and details its Scheme core as well as various extensions.
- Understanding the architecture and basic concepts of Guile and the Scheme programming language.
- Learning how to embed Guile into C/C++ applications, including memory management and garbage collection.
- Exploring the Guile API, including data types, procedures, and macros.
- Overview of standard Guile modules and supported SRFIs (Scheme Requests For Implementation).
- Details on using and creating Guile modules, including dynamic library support.
Auszug aus dem Buch
3.1.4.6 Example 1: A Serial Number Generator
This example uses closure to create a procedure with a variable binding that is private to the procedure, like a local variable, but whose value persists between procedure calls.
(define (make-serial-number-generator)
(let ((current-serial-number 0))
(lambda ()
(set! current-serial-number (+ current-serial-number 1))
current-serial-number)))
(define entry-sn-generator (make-serial-number-generator))
(entry-sn-generator)
⇒
1
(entry-sn-generator)
⇒
2
When make-serial-number-generator is called, it creates a local environment with a binding for current-serial-number whose initial value is 0, then, within this environment, creates a procedure. The local environment is stored within the created procedure object and so persists for the lifetime of the created procedure.
Every time the created procedure is invoked, it increments the value of the current-serial-number binding in the captured environment and then returns the current value.
Note that make-serial-number-generator can be called again to create a second serial number generator that is independent of the first. Every new invocation of make-serial-number-generator creates a new local let environment and returns a new procedure object with an association to this environment.
Summary of Chapters
1 Preface: This section provides an overview of what Guile is, how it is used, and describes the documentation conventions and contributors.
2 Introduction to Guile: This chapter introduces Guile as an interpreter for Scheme, explaining its use as an interactive interpreter, a script interpreter, and an extension library.
3 Programming in Scheme: This chapter covers fundamental concepts for programming in Scheme using Guile, including variables, procedures, expressions, and closures.
4 Programming in C: This chapter details the technical aspects of using Guile in a C program, including linking, defining new data types (smobs), and function snarfing.
5 API Reference: This chapter serves as the primary reference for the Guile API, documenting data types, procedures, and macros for Scheme and C side-by-side.
6 Guile Modules: This chapter describes the modular structure of Guile, including standard modules and support for SRFI (Scheme Request For Implementation) modules.
7 Autoconf Support: This chapter explains how to integrate Guile with the Autoconf build tool to ensure portability across systems.
Keywords
Guile, Scheme, R5RS, SCM, C API, Garbage Collection, Smobs, Modules, SRFI, Interpreter, Extension Language, Scripting, Macros, Debugging, API Reference
Frequently Asked Questions
What is the primary purpose of Guile?
Guile is an interpreter for the Scheme programming language designed to be embedded as an extension or configuration language in other applications, acting as a "glue" for different system components.
What are the main topic areas covered in this manual?
The manual covers general Guile usage, programming in Scheme with Guile, interfacing with C, using Guile modules, and a comprehensive reference to the Guile API.
What is the core programming language of Guile?
The core language is Scheme, specifically implemented to be compliant with the R5RS (Revised 5th Report on the Algorithmic Language Scheme) standard, with various extensions.
How is Guile typically interfaced with C applications?
Guile provides a robust C interface that allows C programs to embed the interpreter, manage Scheme data (as SCM objects), and define new primitive procedures or data types (smobs).
What does the "Programming in C" section treat?
It provides an overview of linking C applications with the Guile library, managing garbage collection for custom types (smobs), and handling control flow when jumping between C and Scheme.
Which keywords best describe this documentation?
The core keywords include Guile, Scheme, R5RS, SCM, C API, Garbage Collection, Smobs, and Modules.
What is a "Smob" in Guile?
A "Smob" (Small Object) is Guile's mechanism for adding new primitive data types to the system, allowing C-defined structures to be handled by the Scheme memory manager.
How does Guile handle garbage collection for custom types?
Guile provides "mark" and "free" functions that the programmer must define for each custom smob type, enabling the garbage collector to correctly trace and deallocate objects.
What is the function of the "Snarfing" tools?
Snarfing tools, like `guile-snarf`, automate the process of keeping initialization calls for C functions in sync with their source code definitions, simplifying the registration of primitives.
- Quote paper
- Hrsg.: Dr. Nikolaus Klepp u.a. (Author), 2008, Guile Reference Manual 1.8.6, Munich, GRIN Verlag, https://www.grin.com/document/123459