85 lines
3.8 KiB
HTML
85 lines
3.8 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>SRFI-4 and Bytevectors (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="SRFI-4 and Bytevectors (Guile Reference Manual)">
|
|
<meta name="keywords" content="SRFI-4 and Bytevectors (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="SRFI_002d4.html" rel="up" title="SRFI-4">
|
|
<link href="SRFI_002d4-Extensions.html" rel="next" title="SRFI-4 Extensions">
|
|
<link href="SRFI_002d4-API.html" rel="prev" title="SRFI-4 API">
|
|
<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="subsubsection-level-extent" id="SRFI_002d4-and-Bytevectors">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="SRFI_002d4-Extensions.html" accesskey="n" rel="next">SRFI-4 - Guile extensions</a>, Previous: <a href="SRFI_002d4-API.html" accesskey="p" rel="prev">SRFI-4 - API</a>, Up: <a href="SRFI_002d4.html" accesskey="u" rel="up">SRFI-4 - Homogeneous numeric vector datatypes</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="SRFI_002d4-_002d-Relation-to-bytevectors"><span>7.5.5.3 SRFI-4 - Relation to bytevectors<a class="copiable-link" href="#SRFI_002d4-_002d-Relation-to-bytevectors"> ¶</a></span></h4>
|
|
|
|
<p>Guile implements SRFI-4 vectors using bytevectors (see <a class="pxref" href="Bytevectors.html">Bytevectors</a>). Often
|
|
when you have a numeric vector, you end up wanting to write its bytes somewhere,
|
|
or have access to the underlying bytes, or read in bytes from somewhere else.
|
|
Bytevectors are very good at this sort of thing. But the SRFI-4 APIs are nicer
|
|
to use when doing number-crunching, because they are addressed by element and
|
|
not by byte.
|
|
</p>
|
|
<p>So as a compromise, Guile allows all bytevector functions to operate on numeric
|
|
vectors. They address the underlying bytes in the native endianness, as one
|
|
would expect.
|
|
</p>
|
|
<p>Following the same reasoning, that it’s just bytes underneath, Guile also allows
|
|
uniform vectors of a given type to be accessed as if they were of any type. One
|
|
can fill a <code class="code">u32vector</code>, and access its elements with
|
|
<code class="code">u8vector-ref</code>. One can use <code class="code">f64vector-ref</code> on bytevectors. It’s
|
|
all the same to Guile.
|
|
</p>
|
|
<p>In this way, uniform numeric vectors may be written to and read from
|
|
input/output ports using the procedures that operate on bytevectors.
|
|
</p>
|
|
<p>See <a class="xref" href="Bytevectors.html">Bytevectors</a>, for more information.
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|