102 lines
4.8 KiB
HTML
102 lines
4.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>Values and Variables (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Values and Variables (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="Values and Variables (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="About-Data.html" rel="up" title="About Data">
|
||
|
<link href="Definition.html" rel="next" title="Definition">
|
||
|
<link href="Latent-Typing.html" rel="prev" title="Latent Typing">
|
||
|
<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="subsection-level-extent" id="Values-and-Variables">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Definition.html" accesskey="n" rel="next">Defining and Setting Variables</a>, Previous: <a href="Latent-Typing.html" accesskey="p" rel="prev">Latent Typing</a>, Up: <a href="About-Data.html" accesskey="u" rel="up">Data Types, Values and Variables</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="subsection" id="Values-and-Variables-1"><span>3.1.2 Values and Variables<a class="copiable-link" href="#Values-and-Variables-1"> ¶</a></span></h4>
|
||
|
|
||
|
<p>Scheme provides many data types that you can use to represent your data.
|
||
|
Primitive types include characters, strings, numbers and procedures.
|
||
|
Compound types, which allow a group of primitive and compound values to
|
||
|
be stored together, include lists, pairs, vectors and multi-dimensional
|
||
|
arrays. In addition, Guile allows applications to define their own data
|
||
|
types, with the same status as the built-in standard Scheme types.
|
||
|
</p>
|
||
|
<p>As a Scheme program runs, values of all types pop in and out of
|
||
|
existence. Sometimes values are stored in variables, but more commonly
|
||
|
they pass seamlessly from being the result of one computation to being
|
||
|
one of the parameters for the next.
|
||
|
</p>
|
||
|
<p>Consider an example. A string value is created because the interpreter
|
||
|
reads in a literal string from your program’s source code. Then a
|
||
|
numeric value is created as the result of calculating the length of the
|
||
|
string. A second numeric value is created by doubling the calculated
|
||
|
length. Finally the program creates a list with two elements – the
|
||
|
doubled length and the original string itself – and stores this list in
|
||
|
a program variable.
|
||
|
</p>
|
||
|
<p>All of the values involved here – in fact, all values in Scheme –
|
||
|
carry their type with them. In other words, every value “knows,” at
|
||
|
runtime, what kind of value it is. A number, a string, a list,
|
||
|
whatever.
|
||
|
</p>
|
||
|
<p>A variable, on the other hand, has no fixed type. A variable –
|
||
|
<code class="code">x</code>, say – is simply the name of a location – a box – in which
|
||
|
you can store any kind of Scheme value. So the same variable in a
|
||
|
program may hold a number at one moment, a list of procedures the next,
|
||
|
and later a pair of strings. The “type” of a variable – insofar as
|
||
|
the idea is meaningful at all – is simply the type of whatever value
|
||
|
the variable happens to be storing at a particular moment.
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Definition.html">Defining and Setting Variables</a>, Previous: <a href="Latent-Typing.html">Latent Typing</a>, Up: <a href="About-Data.html">Data Types, Values and Variables</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>
|