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

133 lines
6.6 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>Buffered Input (Guile Reference Manual)</title>
<meta name="description" content="Buffered Input (Guile Reference Manual)">
<meta name="keywords" content="Buffered Input (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="Guile-Modules.html" rel="up" title="Guile Modules">
<link href="Expect.html" rel="next" title="Expect">
<link href="Streams.html" rel="prev" title="Streams">
<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="section-level-extent" id="Buffered-Input">
<div class="nav-panel">
<p>
Next: <a href="Expect.html" accesskey="n" rel="next">Expect</a>, Previous: <a href="Streams.html" accesskey="p" rel="prev">Streams</a>, Up: <a href="Guile-Modules.html" accesskey="u" rel="up">Guile Modules</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>
<h3 class="section" id="Buffered-Input-1"><span>7.15 Buffered Input<a class="copiable-link" href="#Buffered-Input-1"> &para;</a></span></h3>
<a class="index-entry-id" id="index-Buffered-input"></a>
<a class="index-entry-id" id="index-Line-continuation"></a>
<p>The following functions are provided by
</p>
<div class="example">
<pre class="example-preformatted">(use-modules (ice-9 buffered-input))
</pre></div>
<p>A buffered input port allows a reader function to return chunks of
characters which are to be handed out on reading the port. A notion
of further input for an application level logical expression is
maintained too, and passed through to the reader.
</p>
<dl class="first-deffn">
<dt class="deffn" id="index-make_002dbuffered_002dinput_002dport"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">make-buffered-input-port</strong> <var class="def-var-arguments">reader</var><a class="copiable-link" href="#index-make_002dbuffered_002dinput_002dport"> &para;</a></span></dt>
<dd><p>Create an input port which returns characters obtained from the given
<var class="var">reader</var> function. <var class="var">reader</var> is called (<var class="var">reader</var> cont),
and should return a string or an EOF object.
</p>
<p>The new port gives precisely the characters returned by <var class="var">reader</var>,
nothing is added, so if any newline characters or other separators are
desired they must come from the reader function.
</p>
<p>The <var class="var">cont</var> parameter to <var class="var">reader</var> is <code class="code">#f</code> for initial
input, or <code class="code">#t</code> when continuing an expression. This is an
application level notion, set with
<code class="code">set-buffered-input-continuation?!</code> below. If the user has
entered a partial expression then it allows <var class="var">reader</var> for instance
to give a different prompt to show more is required.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-make_002dline_002dbuffered_002dinput_002dport"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">make-line-buffered-input-port</strong> <var class="def-var-arguments">reader</var><a class="copiable-link" href="#index-make_002dline_002dbuffered_002dinput_002dport"> &para;</a></span></dt>
<dd><a class="index-entry-id" id="index-Line-buffered-input"></a>
<p>Create an input port which returns characters obtained from the
specified <var class="var">reader</var> function, similar to
<code class="code">make-buffered-input-port</code> above, but where <var class="var">reader</var> is
expected to be a line-oriented.
</p>
<p><var class="var">reader</var> is called (<var class="var">reader</var> cont), and should return a string
or an EOF object as above. Each string is a line of input without a
newline character, the port code inserts a newline after each string.
</p></dd></dl>
<dl class="first-deffn">
<dt class="deffn" id="index-set_002dbuffered_002dinput_002dcontinuation_003f_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">set-buffered-input-continuation?!</strong> <var class="def-var-arguments">port cont</var><a class="copiable-link" href="#index-set_002dbuffered_002dinput_002dcontinuation_003f_0021"> &para;</a></span></dt>
<dd><p>Set the input continuation flag for a given buffered input
<var class="var">port</var>.
</p>
<p>An application uses this by calling with a <var class="var">cont</var> flag of
<code class="code">#f</code> when beginning to read a new logical expression. For
example with the Scheme <code class="code">read</code> function (see <a class="pxref" href="Scheme-Read.html">Reading Scheme Code</a>),
</p>
<div class="example">
<pre class="example-preformatted">(define my-port (make-buffered-input-port my-reader))
(set-buffered-input-continuation?! my-port #f)
(let ((obj (read my-port)))
...
</pre></div>
</dd></dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Expect.html">Expect</a>, Previous: <a href="Streams.html">Streams</a>, Up: <a href="Guile-Modules.html">Guile Modules</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>