102 lines
5.1 KiB
HTML
102 lines
5.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<!-- This manual documents Guile version 3.0.10.
|
||
|
|
||
|
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." -->
|
||
|
<title>Combining with C (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Combining with C (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="Combining with C (Guile Reference Manual)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content=".texi2any-real">
|
||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
|
|
||
|
<link href="index.html" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Introduction.html" rel="up" title="Introduction">
|
||
|
<link href="Guile-and-the-GNU-Project.html" rel="next" title="Guile and the GNU Project">
|
||
|
<link href="Guile-and-Scheme.html" rel="prev" title="Guile and Scheme">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
span:hover a.copiable-link {visibility: visible}
|
||
|
-->
|
||
|
</style>
|
||
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<div class="section-level-extent" id="Combining-with-C">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Guile-and-the-GNU-Project.html" accesskey="n" rel="next">Guile and the GNU Project</a>, Previous: <a href="Guile-and-Scheme.html" accesskey="p" rel="prev">Guile and Scheme</a>, Up: <a href="Introduction.html" accesskey="u" rel="up">Introduction</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<h3 class="section" id="Combining-with-C-Code"><span>1.2 Combining with C Code<a class="copiable-link" href="#Combining-with-C-Code"> ¶</a></span></h3>
|
||
|
|
||
|
<p>Like a shell, Guile can run interactively—reading expressions from the user,
|
||
|
evaluating them, and displaying the results—or as a script interpreter,
|
||
|
reading and executing Scheme code from a file. Guile also provides an object
|
||
|
library, <em class="dfn">libguile</em>, that allows other applications to easily incorporate a
|
||
|
complete Scheme interpreter. An application can then use Guile as an extension
|
||
|
language, a clean and powerful configuration language, or as multi-purpose
|
||
|
“glue”, connecting primitives provided by the application. It is easy to call
|
||
|
Scheme code from C code and vice versa, giving the application designer full
|
||
|
control of how and when to invoke the interpreter. Applications can add new
|
||
|
functions, data types, control structures, and even syntax to Guile, creating a
|
||
|
domain-specific language tailored to the task at hand, but based on a robust
|
||
|
language design.
|
||
|
</p>
|
||
|
<p>This kind of combination is helped by four aspects of Guile’s design
|
||
|
and history. First is that Guile has always been targeted as an
|
||
|
extension language. Hence its C API has always been of great
|
||
|
importance, and has been developed accordingly. Second and third are
|
||
|
rather technical points—that Guile uses conservative garbage
|
||
|
collection, and that it implements the Scheme concept of continuations
|
||
|
by copying and reinstating the C stack—but whose practical
|
||
|
consequence is that most existing C code can be glued into Guile as
|
||
|
is, without needing modifications to cope with strange Scheme
|
||
|
execution flows. Last is the module system, which helps extensions to
|
||
|
coexist without stepping on each others’ toes.
|
||
|
</p>
|
||
|
<p>Guile’s module system allows one to break up a large program into
|
||
|
manageable sections with well-defined interfaces between them.
|
||
|
Modules may contain a mixture of interpreted and compiled code; Guile
|
||
|
can use either static or dynamic linking to incorporate compiled code.
|
||
|
Modules also encourage developers to package up useful collections of
|
||
|
routines for general distribution; as of this writing, one can find
|
||
|
Emacs interfaces, database access routines, compilers, <abbr class="acronym">GUI</abbr>
|
||
|
toolkit interfaces, and <abbr class="acronym">HTTP</abbr> client functions, among others.
|
||
|
</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Guile-and-the-GNU-Project.html">Guile and the GNU Project</a>, Previous: <a href="Guile-and-Scheme.html">Guile and Scheme</a>, Up: <a href="Introduction.html">Introduction</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|