134 lines
7.5 KiB
HTML
134 lines
7.5 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>Vtable Contents (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="Vtable Contents (Guile Reference Manual)">
|
|
<meta name="keywords" content="Vtable Contents (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="Structures.html" rel="up" title="Structures">
|
|
<link href="Meta_002dVtables.html" rel="next" title="Meta-Vtables">
|
|
<link href="Structure-Basics.html" rel="prev" title="Structure Basics">
|
|
<style type="text/css">
|
|
<!--
|
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
|
div.example {margin-left: 3.2em}
|
|
span:hover a.copiable-link {visibility: visible}
|
|
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
|
|
-->
|
|
</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="Vtable-Contents">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Meta_002dVtables.html" accesskey="n" rel="next">Meta-Vtables</a>, Previous: <a href="Structure-Basics.html" accesskey="p" rel="prev">Structure Basics</a>, Up: <a href="Structures.html" accesskey="u" rel="up">Structures</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="Vtable-Contents-1"><span>6.6.18.3 Vtable Contents<a class="copiable-link" href="#Vtable-Contents-1"> ¶</a></span></h4>
|
|
|
|
<p>A vtable is itself a structure. It has a specific set of fields
|
|
describing various aspects of its <em class="dfn">instances</em>: the structures
|
|
created from a vtable. Some of the fields are internal to Guile, some
|
|
of them are part of the public interface, and there may be additional
|
|
fields added on by the user.
|
|
</p>
|
|
<p>Every vtable has a field for the layout of their instances, a field for
|
|
the procedure used to print its instances, and a field for the name of
|
|
the vtable itself. Access to the layout and printer is exposed directly
|
|
via field indexes. Access to the vtable name is exposed via accessor
|
|
procedures.
|
|
</p>
|
|
<dl class="first-defvr">
|
|
<dt class="defvr" id="index-vtable_002dindex_002dlayout"><span class="category-def">Scheme Variable: </span><span><strong class="def-name">vtable-index-layout</strong><a class="copiable-link" href="#index-vtable_002dindex_002dlayout"> ¶</a></span></dt>
|
|
<dt class="defvrx def-cmd-defvr" id="index-scm_005fvtable_005findex_005flayout"><span class="category-def">C Macro: </span><span><strong class="def-name">scm_vtable_index_layout</strong><a class="copiable-link" href="#index-scm_005fvtable_005findex_005flayout"> ¶</a></span></dt>
|
|
<dd><p>The field number of the layout specification in a vtable. The layout
|
|
specification is a symbol like <code class="code">pwpw</code> formed from the fields
|
|
string passed to <code class="code">make-vtable</code>, or created by
|
|
<code class="code">make-struct-layout</code> (see <a class="pxref" href="Meta_002dVtables.html">Meta-Vtables</a>).
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example-preformatted">(define v (make-vtable "pwpw" 0))
|
|
(struct-ref v vtable-index-layout) ⇒ pwpw
|
|
</pre></div>
|
|
|
|
<p>This field is read-only, since the layout of structures using a vtable
|
|
cannot be changed.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-defvr">
|
|
<dt class="defvr" id="index-vtable_002dindex_002dprinter"><span class="category-def">Scheme Variable: </span><span><strong class="def-name">vtable-index-printer</strong><a class="copiable-link" href="#index-vtable_002dindex_002dprinter"> ¶</a></span></dt>
|
|
<dt class="defvrx def-cmd-defvr" id="index-scm_005fvtable_005findex_005fprinter"><span class="category-def">C Macro: </span><span><strong class="def-name">scm_vtable_index_printer</strong><a class="copiable-link" href="#index-scm_005fvtable_005findex_005fprinter"> ¶</a></span></dt>
|
|
<dd><p>The field number of the printer function. This field contains <code class="code">#f</code>
|
|
if the default print function should be used.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example-preformatted">(define (my-print-func struct port)
|
|
...)
|
|
(define v (make-vtable "pwpw" my-print-func))
|
|
(struct-ref v vtable-index-printer) ⇒ my-print-func
|
|
</pre></div>
|
|
|
|
<p>This field is writable, allowing the print function to be changed
|
|
dynamically.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-struct_002dvtable_002dname"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">struct-vtable-name</strong> <var class="def-var-arguments">vtable</var><a class="copiable-link" href="#index-struct_002dvtable_002dname"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-set_002dstruct_002dvtable_002dname_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">set-struct-vtable-name!</strong> <var class="def-var-arguments">vtable name</var><a class="copiable-link" href="#index-set_002dstruct_002dvtable_002dname_0021"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fstruct_005fvtable_005fname"><span class="category-def">C Function: </span><span><strong class="def-name">scm_struct_vtable_name</strong> <var class="def-var-arguments">(vtable)</var><a class="copiable-link" href="#index-scm_005fstruct_005fvtable_005fname"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fset_005fstruct_005fvtable_005fname_005fx"><span class="category-def">C Function: </span><span><strong class="def-name">scm_set_struct_vtable_name_x</strong> <var class="def-var-arguments">(vtable, name)</var><a class="copiable-link" href="#index-scm_005fset_005fstruct_005fvtable_005fname_005fx"> ¶</a></span></dt>
|
|
<dd><p>Get or set the name of <var class="var">vtable</var>. <var class="var">name</var> is a symbol and is
|
|
used in the default print function when printing structures created
|
|
from <var class="var">vtable</var>.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example-preformatted">(define v (make-vtable "pw"))
|
|
(set-struct-vtable-name! v 'my-name)
|
|
|
|
(define s (make-struct v 0))
|
|
(display s) -| #<my-name b7ab3ae0:b7ab3730>
|
|
</pre></div>
|
|
</dd></dl>
|
|
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Meta_002dVtables.html">Meta-Vtables</a>, Previous: <a href="Structure-Basics.html">Structure Basics</a>, Up: <a href="Structures.html">Structures</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>
|