119 lines
5.7 KiB
HTML
119 lines
5.7 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>Available Functionality (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Available Functionality (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="Available Functionality (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="Programming-Options.html" rel="up" title="Programming Options">
|
||
|
<link href="Basic-Constraints.html" rel="next" title="Basic Constraints">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
span:hover a.copiable-link {visibility: visible}
|
||
|
ul.mark-bullet {list-style-type: disc}
|
||
|
-->
|
||
|
</style>
|
||
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<div class="subsubsection-level-extent" id="Available-Functionality">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Basic-Constraints.html" accesskey="n" rel="next">Functional and Performance Constraints</a>, Up: <a href="Programming-Options.html" accesskey="u" rel="up">A Choice of Programming Options</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>
|
||
|
<h4 class="subsubsection" id="What-Functionality-is-Already-Available_003f"><span>5.7.4.1 What Functionality is Already Available?<a class="copiable-link" href="#What-Functionality-is-Already-Available_003f"> ¶</a></span></h4>
|
||
|
|
||
|
<p>Suppose, for the sake of argument, that you would prefer to write your
|
||
|
whole application in Scheme. Then the API available to you consists of:
|
||
|
</p>
|
||
|
<ul class="itemize mark-bullet">
|
||
|
<li>standard Scheme
|
||
|
|
||
|
</li><li>plus the extensions to standard Scheme provided by
|
||
|
Guile in its core distribution
|
||
|
|
||
|
</li><li>plus any additional functionality that you or others have packaged so
|
||
|
that it can be loaded as a Guile Scheme module.
|
||
|
</li></ul>
|
||
|
|
||
|
<p>A module in the last category can either be a pure Scheme module — in
|
||
|
other words a collection of utility procedures coded in Scheme — or a
|
||
|
module that provides a Scheme interface to an extension library coded in
|
||
|
C — in other words a nice package where someone else has done the work
|
||
|
of wrapping up some useful C code for you. The set of available modules
|
||
|
is growing quickly and already includes such useful examples as
|
||
|
<code class="code">(gtk gtk)</code>, which makes Gtk+ drawing functions available in
|
||
|
Scheme, and <code class="code">(database postgres)</code>, which provides SQL access to a
|
||
|
Postgres database.
|
||
|
</p>
|
||
|
<p>Given the growing collection of pre-existing modules, it is quite
|
||
|
feasible that your application could be implemented by combining a
|
||
|
selection of these modules together with new application code written in
|
||
|
Scheme.
|
||
|
</p>
|
||
|
<p>If this approach is not enough, because the functionality that your
|
||
|
application needs is not already available in this form, and it is
|
||
|
impossible to write the new functionality in Scheme, you will need to
|
||
|
write some C code. If the required function is already available in C
|
||
|
(e.g. in a library), all you need is a little glue to connect it to the
|
||
|
world of Guile. If not, you need both to write the basic code and to
|
||
|
plumb it into Guile.
|
||
|
</p>
|
||
|
<p>In either case, two general considerations are important. Firstly, what
|
||
|
is the interface by which the functionality is presented to the Scheme
|
||
|
world? Does the interface consist only of function calls (for example,
|
||
|
a simple drawing interface), or does it need to include <em class="dfn">objects</em> of
|
||
|
some kind that can be passed between C and Scheme and manipulated by
|
||
|
both worlds. Secondly, how does the lifetime and memory management of
|
||
|
objects in the C code relate to the garbage collection governed approach
|
||
|
of Scheme objects? In the case where the basic C code is not already
|
||
|
written, most of the difficulties of memory management can be avoided by
|
||
|
using Guile’s C interface features from the start.
|
||
|
</p>
|
||
|
<p>For the full documentation on writing C code for Guile and connecting
|
||
|
existing C code to the Guile world, see <a class="ref" href="Defining-New-Foreign-Object-Types.html">Defining New Foreign Object Types</a>, <a class="ref" href="Primitive-Procedures.html">Primitive Procedures</a>, and <a class="ref" href="Foreign-Function-Interface.html">Foreign Function Interface</a>.
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Basic-Constraints.html">Functional and Performance Constraints</a>, Up: <a href="Programming-Options.html">A Choice of Programming Options</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>
|