116 lines
6.9 KiB
HTML
116 lines
6.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>Non-Immediate Objects (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="Non-Immediate Objects (Guile Reference Manual)">
|
|
<meta name="keywords" content="Non-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="Allocating-Heap-Objects.html" rel="next" title="Allocating Heap Objects">
|
|
<link href="Immediate-Objects.html" rel="prev" title="Immediate Objects">
|
|
<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="Non_002dImmediate-Objects">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Allocating-Heap-Objects.html" accesskey="n" rel="next">Allocating Heap Objects</a>, Previous: <a href="Immediate-Objects.html" accesskey="p" rel="prev">Immediate Objects</a>, Up: <a href="The-SCM-Type-in-Guile.html" accesskey="u" rel="up">The SCM Type in Guile</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="Non_002dImmediate-Objects-1"><span>9.2.5.3 Non-Immediate Objects<a class="copiable-link" href="#Non_002dImmediate-Objects-1"> ¶</a></span></h4>
|
|
|
|
<p>A Scheme object of type <code class="code">SCM</code> that does not fulfill the
|
|
<code class="code">SCM_IMP</code> predicate holds an encoded reference to a heap object.
|
|
This reference can be decoded to a C pointer to a heap object using the
|
|
<code class="code">SCM_UNPACK_POINTER</code> macro. The encoding of a pointer to a heap
|
|
object into a <code class="code">SCM</code> value is done using the <code class="code">SCM_PACK_POINTER</code>
|
|
macro.
|
|
</p>
|
|
<a class="index-entry-id" id="index-cells_002c-deprecated-concept"></a>
|
|
<p>Before Guile 2.0, Guile had a custom garbage collector that allocated
|
|
heap objects in units of 2-word <em class="dfn">cells</em>. With the move to the
|
|
BDW-GC collector in Guile 2.0, Guile can allocate heap objects of any
|
|
size, and the concept of a cell is now obsolete. Still, we mention
|
|
it here as the name still appears in various low-level interfaces.
|
|
</p>
|
|
<dl class="first-deftypefn">
|
|
<dt class="deftypefn" id="index-SCM_005fUNPACK_005fPOINTER"><span class="category-def">Macro: </span><span><code class="def-type">scm_t_bits *</code> <strong class="def-name">SCM_UNPACK_POINTER</strong> <code class="def-code-arguments">(SCM <var class="var">x</var>)</code><a class="copiable-link" href="#index-SCM_005fUNPACK_005fPOINTER"> ¶</a></span></dt>
|
|
<dt class="deftypefnx def-cmd-deftypefn" id="index-SCM2PTR"><span class="category-def">Macro: </span><span><code class="def-type">scm_t_cell *</code> <strong class="def-name">SCM2PTR</strong> <code class="def-code-arguments">(SCM <var class="var">x</var>)</code><a class="copiable-link" href="#index-SCM2PTR"> ¶</a></span></dt>
|
|
<dd><p>Extract and return the heap object pointer from a non-immediate
|
|
<code class="code">SCM</code> object <var class="var">x</var>. The name <code class="code">SCM2PTR</code> is deprecated but
|
|
still common.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deftypefn">
|
|
<dt class="deftypefn" id="index-_0028scm_005ft_005fbits"><span class="category-def">Macro: </span><span><code class="def-type">SCM_PACK_POINTER</code> <strong class="def-name">(scm_t_bits</strong> <code class="def-code-arguments">* <var class="var">x</var>)</code><a class="copiable-link" href="#index-_0028scm_005ft_005fbits"> ¶</a></span></dt>
|
|
<dt class="deftypefnx def-cmd-deftypefn" id="index-PTR2SCM"><span class="category-def">Macro: </span><span><code class="def-type">SCM</code> <strong class="def-name">PTR2SCM</strong> <code class="def-code-arguments">(scm_t_cell * <var class="var">x</var>)</code><a class="copiable-link" href="#index-PTR2SCM"> ¶</a></span></dt>
|
|
<dd><p>Return a <code class="code">SCM</code> value that encodes a reference to the heap object
|
|
pointer <var class="var">x</var>. The name <code class="code">PTR2SCM</code> is deprecated but still
|
|
common.
|
|
</p></dd></dl>
|
|
|
|
<p>Note that it is also possible to transform a non-immediate <code class="code">SCM</code>
|
|
value by using <code class="code">SCM_UNPACK</code> into a <code class="code">scm_t_bits</code> variable.
|
|
However, the result of <code class="code">SCM_UNPACK</code> may not be used as a pointer to
|
|
a heap object: only <code class="code">SCM_UNPACK_POINTER</code> is guaranteed to transform
|
|
a <code class="code">SCM</code> object into a valid pointer to a heap object. Also, it is
|
|
not allowed to apply <code class="code">SCM_PACK_POINTER</code> to anything that is not a
|
|
valid pointer to a heap object.
|
|
</p>
|
|
<p>Summary:
|
|
</p><ul class="itemize mark-bullet">
|
|
<li>Only use <code class="code">SCM_UNPACK_POINTER</code> on <code class="code">SCM</code> values for which
|
|
<code class="code">SCM_IMP</code> is false!
|
|
</li><li>Don’t use <code class="code">(scm_t_cell *) SCM_UNPACK (<var class="var">x</var>)</code>! Use
|
|
<code class="code">SCM_UNPACK_POINTER (<var class="var">x</var>)</code> instead!
|
|
</li><li>Don’t use <code class="code">SCM_PACK_POINTER</code> for anything but a heap object pointer!
|
|
</li></ul>
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Allocating-Heap-Objects.html">Allocating Heap Objects</a>, Previous: <a href="Immediate-Objects.html">Immediate Objects</a>, Up: <a href="The-SCM-Type-in-Guile.html">The SCM Type in Guile</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>
|