1
0
Fork 0
cl-sites/guile.html_node/Immediate-Objects.html
2024-12-17 12:49:28 +01:00

143 lines
7.9 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>Immediate Objects (Guile Reference Manual)</title>
<meta name="description" content="Immediate Objects (Guile Reference Manual)">
<meta name="keywords" content="Immediate Objects (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="The-SCM-Type-in-Guile.html" rel="up" title="The SCM Type in Guile">
<link href="Non_002dImmediate-Objects.html" rel="next" title="Non-Immediate Objects">
<link href="Relationship-Between-SCM-and-scm_005ft_005fbits.html" rel="prev" title="Relationship Between SCM and scm_t_bits">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
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="Immediate-Objects">
<div class="nav-panel">
<p>
Next: <a href="Non_002dImmediate-Objects.html" accesskey="n" rel="next">Non-Immediate Objects</a>, Previous: <a href="Relationship-Between-SCM-and-scm_005ft_005fbits.html" accesskey="p" rel="prev">Relationship Between <code class="code">SCM</code> and <code class="code">scm_t_bits</code></a>, Up: <a href="The-SCM-Type-in-Guile.html" accesskey="u" rel="up">The SCM Type in Guile</a> &nbsp; [<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="Immediate-Objects-1"><span>9.2.5.2 Immediate Objects<a class="copiable-link" href="#Immediate-Objects-1"> &para;</a></span></h4>
<p>A Scheme object may either be an immediate, i.e. carrying all
necessary information by itself, or it may contain a reference to a
<em class="dfn">heap object</em> which is, as the name implies, data on the heap.
Although in general it should be irrelevant for user code whether an
object is an immediate or not, within Guile&rsquo;s own code the distinction
is sometimes of importance. Thus, the following low level macro is
provided:
</p>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-SCM_005fIMP"><span class="category-def">Macro: </span><span><code class="def-type">int</code> <strong class="def-name">SCM_IMP</strong> <code class="def-code-arguments">(SCM <var class="var">x</var>)</code><a class="copiable-link" href="#index-SCM_005fIMP"> &para;</a></span></dt>
<dd><p>A Scheme object is an immediate if it fulfills the <code class="code">SCM_IMP</code>
predicate, otherwise it holds an encoded reference to a heap object. The
result of the predicate is delivered as a C style boolean value. User
code and code that extends Guile should normally not be required to use
this macro.
</p></dd></dl>
<p>Summary:
</p><ul class="itemize mark-bullet">
<li>Given a Scheme object <var class="var">x</var> of unknown type, check first
with <code class="code">SCM_IMP (<var class="var">x</var>)</code> if it is an immediate object.
</li><li>If so, all of the type and value information can be determined from the
<code class="code">scm_t_bits</code> value that is delivered by <code class="code">SCM_UNPACK
(<var class="var">x</var>)</code>.
</li></ul>
<p>There are a number of special values in Scheme, most of them documented
elsewhere in this manual. It&rsquo;s not quite the right place to put them,
but for now, here&rsquo;s a list of the C names given to some of these values:
</p>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-SCM_005fEOL"><span class="category-def">Macro: </span><span><code class="def-type">SCM</code> <strong class="def-name">SCM_EOL</strong><a class="copiable-link" href="#index-SCM_005fEOL"> &para;</a></span></dt>
<dd><p>The Scheme empty list object, or &ldquo;End Of List&rdquo; object, usually written
in Scheme as <code class="code">'()</code>.
</p></dd></dl>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-SCM_005fEOF_005fVAL"><span class="category-def">Macro: </span><span><code class="def-type">SCM</code> <strong class="def-name">SCM_EOF_VAL</strong><a class="copiable-link" href="#index-SCM_005fEOF_005fVAL"> &para;</a></span></dt>
<dd><p>The Scheme end-of-file value. It has no standard written
representation, for obvious reasons.
</p></dd></dl>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-SCM_005fUNSPECIFIED"><span class="category-def">Macro: </span><span><code class="def-type">SCM</code> <strong class="def-name">SCM_UNSPECIFIED</strong><a class="copiable-link" href="#index-SCM_005fUNSPECIFIED"> &para;</a></span></dt>
<dd><p>The value returned by some (but not all) expressions that the Scheme
standard says return an &ldquo;unspecified&rdquo; value.
</p>
<p>This is sort of a weirdly literal way to take things, but the standard
read-eval-print loop prints nothing when the expression returns this
value, so it&rsquo;s not a bad idea to return this when you can&rsquo;t think of
anything else helpful.
</p></dd></dl>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-SCM_005fUNDEFINED"><span class="category-def">Macro: </span><span><code class="def-type">SCM</code> <strong class="def-name">SCM_UNDEFINED</strong><a class="copiable-link" href="#index-SCM_005fUNDEFINED"> &para;</a></span></dt>
<dd><p>The &ldquo;undefined&rdquo; value. Its most important property is that is not
equal to any valid Scheme value. This is put to various internal uses
by C code interacting with Guile.
</p>
<p>For example, when you write a C function that is callable from Scheme
and which takes optional arguments, the interpreter passes
<code class="code">SCM_UNDEFINED</code> for any arguments you did not receive.
</p>
<p>We also use this to mark unbound variables.
</p></dd></dl>
<dl class="first-deftypefn">
<dt class="deftypefn" id="index-SCM_005fUNBNDP"><span class="category-def">Macro: </span><span><code class="def-type">int</code> <strong class="def-name">SCM_UNBNDP</strong> <code class="def-code-arguments">(SCM <var class="var">x</var>)</code><a class="copiable-link" href="#index-SCM_005fUNBNDP"> &para;</a></span></dt>
<dd><p>Return true if <var class="var">x</var> is <code class="code">SCM_UNDEFINED</code>. Note that this is not a
check to see if <var class="var">x</var> is <code class="code">SCM_UNBOUND</code>. History will not be kind
to us.
</p></dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Non_002dImmediate-Objects.html">Non-Immediate Objects</a>, Previous: <a href="Relationship-Between-SCM-and-scm_005ft_005fbits.html">Relationship Between <code class="code">SCM</code> and <code class="code">scm_t_bits</code></a>, Up: <a href="The-SCM-Type-in-Guile.html">The SCM Type in Guile</a> &nbsp; [<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>