1103 lines
89 KiB
HTML
1103 lines
89 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html>
|
|||
|
<!-- Created by GNU Texinfo 7.0.3, https://www.gnu.org/software/texinfo/ -->
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|||
|
<title>Manipulating Lisp objects (ECL Manual)</title>
|
|||
|
|
|||
|
<meta name="description" content="Manipulating Lisp objects (ECL Manual)">
|
|||
|
<meta name="keywords" content="Manipulating Lisp objects (ECL Manual)">
|
|||
|
<meta name="resource-type" content="document">
|
|||
|
<meta name="distribution" content="global">
|
|||
|
<meta name="Generator" content="makeinfo">
|
|||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|||
|
|
|||
|
<link href="index.html" rel="start" title="Top">
|
|||
|
<link href="Indexes.html" rel="index" title="Indexes">
|
|||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|||
|
<link href="Developer_0027s-guide.html" rel="up" title="Developer's guide">
|
|||
|
<link href="Environment-implementation.html" rel="next" title="Environment implementation">
|
|||
|
<link href="Defun-preprocessor.html" rel="prev" title="Defun preprocessor">
|
|||
|
<style type="text/css">
|
|||
|
<!--
|
|||
|
/* colors */
|
|||
|
|
|||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
|||
|
div.example {margin-left: 3.2em}
|
|||
|
span.r {font-family: initial; font-weight: normal; font-style: normal}
|
|||
|
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}
|
|||
|
@media (prefers-color-scheme: dark) {
|
|||
|
/* dark theme */
|
|||
|
html { color: seashell;
|
|||
|
background: #1A1A1A; }
|
|||
|
body { background: #1A1A1A; }
|
|||
|
th { border-bottom: 2px solid lightgray; }
|
|||
|
h1, h2, h3, h4, h5 { background-image: linear-gradient(to left, #202020, #3A3A3A); }
|
|||
|
code, var, code a { color: darkorange;
|
|||
|
background: #2A2A2A; }
|
|||
|
a { color: seashell; }
|
|||
|
pre { background: #2A2A2A;
|
|||
|
color: seashell;
|
|||
|
/* mark longer code block with stripe on the left */
|
|||
|
border-left: 5px solid darkorange;
|
|||
|
padding-left: 10px; }
|
|||
|
pre.screen { background: #2A2A2A;
|
|||
|
border: 1px solid lightgray; }
|
|||
|
pre.programlisting { background: #2A2A2A;
|
|||
|
border-left: 1px solid lightgray;
|
|||
|
border-top: 1px solid lightgray; }
|
|||
|
/* we need a light background in order for the images to be readable */
|
|||
|
img { background: white }
|
|||
|
}
|
|||
|
@media (prefers-color-scheme: light) {
|
|||
|
/* light theme */
|
|||
|
html { background: white }
|
|||
|
body { background: white }
|
|||
|
th { border-bottom: 2px solid gray; }
|
|||
|
h1, h2, h3, h4, h5 { background: lightgray; }
|
|||
|
code, var, code a { color: darkred;
|
|||
|
background: whitesmoke; }
|
|||
|
a { color: #000; }
|
|||
|
pre { background: whitesmoke;
|
|||
|
color: black;
|
|||
|
/* mark longer code block with stripe on the left */
|
|||
|
border-left: 5px solid darkred;
|
|||
|
padding-left: 10px; }
|
|||
|
pre.screen { background: #EEE;
|
|||
|
border: 1px solid black; }
|
|||
|
pre.programlisting { background: #EEEEEE;
|
|||
|
border-left: 1px solid black;
|
|||
|
border-top: 1px solid black; }
|
|||
|
}
|
|||
|
|
|||
|
body {
|
|||
|
margin: 1em 125px 0 10%;
|
|||
|
line-height: 1.5em;
|
|||
|
padding: 0 2em 1em 2em;
|
|||
|
font: 13px Verdana,Arial, sans-serif
|
|||
|
}
|
|||
|
ul, dd, dl, dt { margin-top: 0; margin-bottom: 0; }
|
|||
|
p, code, td, dl, dt {
|
|||
|
line-height: 1.5em;
|
|||
|
}
|
|||
|
table {
|
|||
|
font: inherit;
|
|||
|
border-collapse: collapse;
|
|||
|
}
|
|||
|
th, td {
|
|||
|
vertical-align: top;
|
|||
|
}
|
|||
|
h1, h2, h3 { padding-left: 15px; }
|
|||
|
h4, h5 { padding-left: 5px; }
|
|||
|
code, pre {
|
|||
|
font-size: 1em;
|
|||
|
font-family: monospace;
|
|||
|
}
|
|||
|
var {
|
|||
|
font-size: 1em;
|
|||
|
}
|
|||
|
/* links inside code appear the same as the code itself */
|
|||
|
code a {
|
|||
|
font-weight: normal;
|
|||
|
text-decoration: none;
|
|||
|
}
|
|||
|
/* but get an underline when hovering */
|
|||
|
code a:hover {
|
|||
|
text-decoration: underline;
|
|||
|
}
|
|||
|
/* ordinary links appear in bold */
|
|||
|
a { font-weight: bold; }
|
|||
|
pre.verbatim {
|
|||
|
margin: 0 0 0 0;
|
|||
|
}
|
|||
|
pre {
|
|||
|
overflow: auto;
|
|||
|
}
|
|||
|
pre.screen {
|
|||
|
font-weight: bold;
|
|||
|
padding: 0.5em;
|
|||
|
}
|
|||
|
pre.programlisting {
|
|||
|
padding: 0.5em;
|
|||
|
}
|
|||
|
div p { padding: 0 2em }
|
|||
|
li p { padding: 0; margin: 0 }
|
|||
|
hr { display: none; }
|
|||
|
div.funcsynopsis p {
|
|||
|
text-indent: -2em;
|
|||
|
}
|
|||
|
div.variablelist {
|
|||
|
padding: 0 2em;
|
|||
|
}
|
|||
|
.type, .funcsynopsis, .symbol {
|
|||
|
font-family: monospace;
|
|||
|
}
|
|||
|
.type, .symbol, .replaceable {
|
|||
|
white-space: nowrap;
|
|||
|
}
|
|||
|
|
|||
|
-->
|
|||
|
</style>
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
|
|||
|
<body lang="en">
|
|||
|
<div class="section-level-extent" id="Manipulating-Lisp-objects">
|
|||
|
<div class="nav-panel">
|
|||
|
<p>
|
|||
|
Next: <a href="Environment-implementation.html" accesskey="n" rel="next">Environment implementation</a>, Previous: <a href="Defun-preprocessor.html" accesskey="p" rel="prev">Defun preprocessor</a>, Up: <a href="Developer_0027s-guide.html" accesskey="u" rel="up">Developer’s guide</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indexes.html" title="Index" rel="index">Index</a>]</p>
|
|||
|
</div>
|
|||
|
<h3 class="section" id="Manipulating-Lisp-objects-1">4.4 Manipulating Lisp objects</h3>
|
|||
|
|
|||
|
|
|||
|
<p>If you want to extend, fix or simply customize ECL for your own needs,
|
|||
|
you should understand how the implementation works.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="cl_005flispunion"></a><a class="index-entry-id" id="index-cl_005flispunion"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-cl_005flispunion-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">cl_lispunion</strong> <var class="def-var-arguments">cons big ratio SF DF longfloat gencomplex csfloat cdfloat clfloat symbol pack hash array vector base_string string stream random readtable pathname bytecodes bclosure cfun cfunfixed cclosure d instance process queue lock rwlock condition_variable semaphore barrier mailbox cblock foreign frame weak sse</var><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-cl_005flispunion-1'> ¶</a></span></dt>
|
|||
|
<dd>
|
|||
|
<p>Union containing all first-class ECL types.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<ul class="mini-toc">
|
|||
|
<li><a href="Manipulating-Lisp-objects.html#Objects-representation" accesskey="1">Objects representation</a></li>
|
|||
|
<li><a href="Manipulating-Lisp-objects.html#Constructing-objects" accesskey="2">Constructing objects</a></li>
|
|||
|
</ul>
|
|||
|
<hr>
|
|||
|
<div class="subsection-level-extent" id="Objects-representation">
|
|||
|
<div class="nav-panel">
|
|||
|
<p>
|
|||
|
Next: <a href="Manipulating-Lisp-objects.html#Constructing-objects" accesskey="n" rel="next">Constructing objects</a>, Up: <a href="Manipulating-Lisp-objects.html#Manipulating-Lisp-objects" accesskey="u" rel="up">Manipulating Lisp objects</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indexes.html" title="Index" rel="index">Index</a>]</p>
|
|||
|
</div>
|
|||
|
<h4 class="subsection" id="Objects-representation-1">4.4.1 Objects representation</h4>
|
|||
|
<p>In ECL a lisp object is represented by a type called
|
|||
|
<code class="code">cl_object</code>. This type is a word which is long enough to host both
|
|||
|
an integer and a pointer. The least significant bits of this word, also
|
|||
|
called the tag bits, determine whether it is a pointer to a C structure
|
|||
|
representing a complex object, or whether it is an immediate data, such
|
|||
|
as a fixnum or a character.
|
|||
|
</p>
|
|||
|
<div class="float" id="fig_003aimmediate_005ftypes">
|
|||
|
|
|||
|
<img class="image" src="figures/immediate-types.png" alt="figures/immediate-types">
|
|||
|
<div class="caption"><p><strong class="strong">Figure 4.1: </strong>Immediate types</p></div></div>
|
|||
|
<p>The topic of the immediate values and bit fiddling is nicely described
|
|||
|
in
|
|||
|
<a class="url" href="http://www.more-magic.net/posts/internals-data-representation.html">Peter Bex’s blog</a> describing <a class="url" href="http://www.call-cc.org/">Chicken
|
|||
|
Scheme</a> internal data representation. We could borrow some ideas from it
|
|||
|
(like improving <code class="code">fixnum</code> bitness and providing more immediate
|
|||
|
values). All changes to code related to immediate values should be
|
|||
|
carefully <strong class="strong">benchmarked</strong>.
|
|||
|
</p>
|
|||
|
<p>The <code class="code">fixnums</code> and characters are called immediate data types,
|
|||
|
because they require no more than the <code class="code">cl_object</code> datatype to store
|
|||
|
all information. All other ECL objects are non-immediate and they are
|
|||
|
represented by a pointer to a cell that is allocated on the heap. Each
|
|||
|
cell consists of several words of memory and contains all the
|
|||
|
information related to that object. By storing data in multiples of a
|
|||
|
word size, we make sure that the least significant bits of a pointer are
|
|||
|
zero, which distinguishes pointers from immediate data.
|
|||
|
</p>
|
|||
|
<p>In an immediate datatype, the tag bits determine the type of the
|
|||
|
object. In non-immediate datatypes, the first byte in the cell contains
|
|||
|
the secondary type indicator, and distinguishes between different types
|
|||
|
of non immediate data. The use of the remaining bytes differs for each
|
|||
|
type of object. For instance, a cons cell consists of three words:
|
|||
|
</p>
|
|||
|
<pre class="verbatim">+---------+----------+
|
|||
|
| CONS | |
|
|||
|
+---------+----------+
|
|||
|
| car-pointer |
|
|||
|
+--------------------+
|
|||
|
| cdr-pointer |
|
|||
|
+--------------------+
|
|||
|
</pre>
|
|||
|
<a class="index-entry-id" id="index-_002d_002denable_002dsmall_002dcons-_005bYES_007cno_005d"></a>
|
|||
|
|
|||
|
<p>Note, that this is one of the possible implementation of
|
|||
|
<code class="code">cons</code>. The second one (currently default) uses the immediate value
|
|||
|
for the <code class="code">list</code> and consumes two words instead of three. Such
|
|||
|
implementation is more memory and speed efficient (according to the
|
|||
|
comments in the source code):
|
|||
|
</p>
|
|||
|
<pre class="verbatim">/*
|
|||
|
* CONSES
|
|||
|
*
|
|||
|
* We implement two variants. The "small cons" type carries the type
|
|||
|
* information in the least significant bits of the pointer. We have
|
|||
|
* to do some pointer arithmetics to find out the CAR / CDR of the
|
|||
|
* cons but the overall result is faster and memory efficient, only
|
|||
|
* using two words per cons.
|
|||
|
*
|
|||
|
* The other scheme stores conses as three-words objects, the first
|
|||
|
* word carrying the type information. This is kept for backward
|
|||
|
* compatibility and also because the oldest garbage collector does
|
|||
|
* not yet support the smaller datatype.
|
|||
|
*
|
|||
|
* To make code portable and independent of the representation, only
|
|||
|
* access the objects using the common macros below (that is all
|
|||
|
* except ECL_CONS_PTR or ECL_PTR_CONS).
|
|||
|
*/
|
|||
|
</pre>
|
|||
|
<a class="anchor" id="cl_005fobject"></a><a class="index-entry-id" id="index-cl_005fobject"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-cl_005fobject-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">cl_object</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-cl_005fobject-1'> ¶</a></span></dt>
|
|||
|
<dd><p>This is the type of a lisp object. For your C/C++ program, a cl_object
|
|||
|
can be either a fixnum, a character, or a pointer to a union of
|
|||
|
structures (See <code class="code">cl_lispunion</code> in the header object.h). The actual
|
|||
|
interpretation of that object can be guessed with the macro
|
|||
|
<code class="code">ecl_t_of</code>.
|
|||
|
</p>
|
|||
|
<h4 class="subsubheading" id="Example-1">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-cl_005fobject-checking-the-type-with-ecl_005ft_005fof"></a>
|
|||
|
|
|||
|
<p>For example, if x is of type cl_object, and it is of type fixnum, we may
|
|||
|
retrieve its value:
|
|||
|
</p>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">if (ecl_t_of(x) == t_fixnum)
|
|||
|
printf("Integer value: %d\n", ecl_fixnum(x));
|
|||
|
</pre></div>
|
|||
|
|
|||
|
<h4 class="subsubheading" id="Example-2">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-Accessing-underlying-cl_005fobject-structure"></a>
|
|||
|
|
|||
|
<p>If <code class="code">x</code> is of type <code class="code">cl_object</code> and it does not contain an
|
|||
|
immediate datatype, you may inspect the cell associated to the lisp
|
|||
|
object using <code class="code">x</code> as a pointer. For example:
|
|||
|
</p>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">if (ecl_t_of(x) == t_vector)
|
|||
|
printf("Vector's dimension is: %d\n", x->vector.dim);
|
|||
|
</pre></div>
|
|||
|
|
|||
|
<p>You should see the following sections and the header object.h to learn
|
|||
|
how to use the different fields of a <code class="code">cl_object</code> pointer.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-cl_005ftype"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">cl_type</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-cl_005ftype'> ¶</a></span></dt>
|
|||
|
<dd><p>Enumeration type which distinguishes the different types of lisp
|
|||
|
objects. The most important values are:
|
|||
|
</p>
|
|||
|
<a class="anchor" id="t_005fstart"></a><a class="index-entry-id" id="index-t_005fstart"></a>
|
|||
|
<a class="anchor" id="t_005flist"></a><a class="index-entry-id" id="index-t_005flist"></a>
|
|||
|
<a class="anchor" id="t_005fcharacter"></a><a class="index-entry-id" id="index-t_005fcharacter"></a>
|
|||
|
<a class="anchor" id="t_005ffixnum"></a><a class="index-entry-id" id="index-t_005ffixnum"></a>
|
|||
|
<a class="anchor" id="t_005fbignum"></a><a class="index-entry-id" id="index-t_005fbignum"></a>
|
|||
|
<a class="anchor" id="t_005fratio"></a><a class="index-entry-id" id="index-t_005fratio"></a>
|
|||
|
<a class="anchor" id="t_005fsinglefloat"></a><a class="index-entry-id" id="index-t_005fsinglefloat"></a>
|
|||
|
<a class="anchor" id="t_005flongfloat"></a><a class="index-entry-id" id="index-t_005flongfloat"></a>
|
|||
|
<a class="anchor" id="t_005fcomplex"></a><a class="index-entry-id" id="index-t_005fcomplex"></a>
|
|||
|
<a class="anchor" id="t_005fcsfloat"></a><a class="index-entry-id" id="index-t_005fcsfloat"></a>
|
|||
|
<a class="anchor" id="t_005fcdfloat"></a><a class="index-entry-id" id="index-t_005fcdfloat"></a>
|
|||
|
<a class="anchor" id="t_005fclfloat"></a><a class="index-entry-id" id="index-t_005fclfloat"></a>
|
|||
|
<a class="anchor" id="t_005fsymbol"></a><a class="index-entry-id" id="index-t_005fsymbol"></a>
|
|||
|
<a class="anchor" id="t_005fpackage"></a><a class="index-entry-id" id="index-t_005fpackage"></a>
|
|||
|
<a class="anchor" id="t_005fhashtable"></a><a class="index-entry-id" id="index-t_005fhashtable"></a>
|
|||
|
<a class="anchor" id="t_005farray"></a><a class="index-entry-id" id="index-t_005farray"></a>
|
|||
|
<a class="anchor" id="t_005fvector"></a><a class="index-entry-id" id="index-t_005fvector"></a>
|
|||
|
<a class="anchor" id="t_005fstring"></a><a class="index-entry-id" id="index-t_005fstring"></a>
|
|||
|
<a class="anchor" id="t_005fbase_005fstring"></a><a class="index-entry-id" id="index-t_005fbase_005fstring"></a>
|
|||
|
<a class="anchor" id="t_005fbitvector"></a><a class="index-entry-id" id="index-t_005fbitvector"></a>
|
|||
|
<a class="anchor" id="t_005fstream"></a><a class="index-entry-id" id="index-t_005fstream"></a>
|
|||
|
<a class="anchor" id="t_005frandom"></a><a class="index-entry-id" id="index-t_005frandom"></a>
|
|||
|
<a class="anchor" id="t_005freadtable"></a><a class="index-entry-id" id="index-t_005freadtable"></a>
|
|||
|
<a class="anchor" id="t_005fpathname"></a><a class="index-entry-id" id="index-t_005fpathname"></a>
|
|||
|
<a class="anchor" id="t_005fbytecodes"></a><a class="index-entry-id" id="index-t_005fbytecodes"></a>
|
|||
|
<a class="anchor" id="t_005fbclosure"></a><a class="index-entry-id" id="index-t_005fbclosure"></a>
|
|||
|
<a class="anchor" id="t_005fcfun"></a><a class="index-entry-id" id="index-t_005fcfun"></a>
|
|||
|
<a class="anchor" id="t_005fcfunfixed"></a><a class="index-entry-id" id="index-t_005fcfunfixed"></a>
|
|||
|
<a class="anchor" id="t_005fcclosure"></a><a class="index-entry-id" id="index-t_005fcclosure"></a>
|
|||
|
<a class="anchor" id="t_005finstance"></a><a class="index-entry-id" id="index-t_005finstance"></a>
|
|||
|
<a class="anchor" id="t_005fstructure-_003d-t_005finstance"></a><a class="index-entry-id" id="index-t_005fstructure-_003d-t_005finstance"></a>
|
|||
|
<a class="anchor" id="t_005fprocess"></a><a class="index-entry-id" id="index-t_005fprocess"></a>
|
|||
|
<a class="anchor" id="t_005flock"></a><a class="index-entry-id" id="index-t_005flock"></a>
|
|||
|
<a class="anchor" id="t_005frwlock"></a><a class="index-entry-id" id="index-t_005frwlock"></a>
|
|||
|
<a class="anchor" id="t_005fcondition_005fvariable"></a><a class="index-entry-id" id="index-t_005fcondition_005fvariable"></a>
|
|||
|
<a class="anchor" id="t_005fsemaphore"></a><a class="index-entry-id" id="index-t_005fsemaphore"></a>
|
|||
|
<a class="anchor" id="t_005fbarrier"></a><a class="index-entry-id" id="index-t_005fbarrier"></a>
|
|||
|
<a class="anchor" id="t_005fmailbox"></a><a class="index-entry-id" id="index-t_005fmailbox"></a>
|
|||
|
<a class="anchor" id="t_005fcodeblock"></a><a class="index-entry-id" id="index-t_005fcodeblock"></a>
|
|||
|
<a class="anchor" id="t_005fforeign"></a><a class="index-entry-id" id="index-t_005fforeign"></a>
|
|||
|
<a class="anchor" id="t_005fframe"></a><a class="index-entry-id" id="index-t_005fframe"></a>
|
|||
|
<a class="anchor" id="t_005fweak_005fpointer"></a><a class="index-entry-id" id="index-t_005fweak_005fpointer"></a>
|
|||
|
<a class="anchor" id="t_005fsse_005fpack"></a><a class="index-entry-id" id="index-t_005fsse_005fpack"></a>
|
|||
|
<a class="anchor" id="t_005fend"></a><a class="index-entry-id" id="index-t_005fend"></a>
|
|||
|
<a class="anchor" id="t_005fother"></a><a class="index-entry-id" id="index-t_005fother"></a>
|
|||
|
<a class="anchor" id="t_005fcontiguous-_2013-contiguous-block"></a><a class="index-entry-id" id="index-t_005fcontiguous-_002d-contiguous-block"></a>
|
|||
|
|
|||
|
<p><code class="code">t_cons</code> <code class="code">t_fixnum</code>, <code class="code">t_character</code>, <code class="code">t_bignum</code>,
|
|||
|
<code class="code">t_ratio</code>, <code class="code">t_singlefloat</code>, <code class="code">t_doublefloat</code>,
|
|||
|
<code class="code">t_complex</code>, <code class="code">t_symbol</code>, <code class="code">t_package</code>, <code class="code">t_hashtable</code>,
|
|||
|
<code class="code">t_array</code>, <code class="code">t_vector</code>, <code class="code">t_string</code>, <code class="code">t_bitvector</code>,
|
|||
|
<code class="code">t_stream</code>, <code class="code">t_random</code>, <code class="code">t_readtable</code>, <code class="code">t_pathname</code>,
|
|||
|
<code class="code">t_bytecodes</code>, <code class="code">t_cfun</code>, <code class="code">t_cclosure</code>, <code class="code">t_gfun</code>,
|
|||
|
<code class="code">t_instance</code>, <code class="code">t_foreign</code> and <code class="code">t_thread</code>.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005ft_005fof"></a><a class="index-entry-id" id="index-ecl_005ft_005fof"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005ft_005fof-1"><span class="category-def">Function: </span><span><code class="def-type">cl_type</code> <strong class="def-name">ecl_t_of</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ft_005fof-1'> ¶</a></span></dt>
|
|||
|
<dd><p>If <var class="var">x</var> is a valid lisp object, <code class="code">ecl_t_of(x)</code> returns an integer
|
|||
|
denoting the type that lisp object. That integer is one of the values of
|
|||
|
the enumeration type <code class="code">cl_type</code>.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ECL_005fCHARACTERP"></a><a class="index-entry-id" id="index-ECL_005fCHARACTERP"></a>
|
|||
|
<a class="anchor" id="ECL_005fBASE_005fCHAR_005fP"></a><a class="index-entry-id" id="index-ECL_005fBASE_005fCHAR_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fBASE_005fCHAR_005fCODE_005fP"></a><a class="index-entry-id" id="index-ECL_005fBASE_005fCHAR_005fCODE_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fNUMBER_005fTYPE_005fP"></a><a class="index-entry-id" id="index-ECL_005fNUMBER_005fTYPE_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fCOMPLEXP"></a><a class="index-entry-id" id="index-ECL_005fCOMPLEXP"></a>
|
|||
|
<a class="anchor" id="ECL_005fREAL_005fTYPE_005fP"></a><a class="index-entry-id" id="index-ECL_005fREAL_005fTYPE_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fFIXNUMP"></a><a class="index-entry-id" id="index-ECL_005fFIXNUMP"></a>
|
|||
|
<a class="anchor" id="ECL_005fBIGNUMP"></a><a class="index-entry-id" id="index-ECL_005fBIGNUMP"></a>
|
|||
|
<a class="anchor" id="ECL_005fSINGLE_005fFLOAT_005fP"></a><a class="index-entry-id" id="index-ECL_005fSINGLE_005fFLOAT_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fDOUBLE_005fFLOAT_005fP"></a><a class="index-entry-id" id="index-ECL_005fDOUBLE_005fFLOAT_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fLONG_005fFLOAT_005fP"></a><a class="index-entry-id" id="index-ECL_005fLONG_005fFLOAT_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fCONSP"></a><a class="index-entry-id" id="index-ECL_005fCONSP"></a>
|
|||
|
<a class="anchor" id="ECL_005fLISTP"></a><a class="index-entry-id" id="index-ECL_005fLISTP"></a>
|
|||
|
<a class="anchor" id="ECL_005fATOM"></a><a class="index-entry-id" id="index-ECL_005fATOM"></a>
|
|||
|
<a class="anchor" id="ECL_005fSYMBOLP"></a><a class="index-entry-id" id="index-ECL_005fSYMBOLP"></a>
|
|||
|
<a class="anchor" id="ECL_005fARRAYP"></a><a class="index-entry-id" id="index-ECL_005fARRAYP"></a>
|
|||
|
<a class="anchor" id="ECL_005fVECTORP"></a><a class="index-entry-id" id="index-ECL_005fVECTORP"></a>
|
|||
|
<a class="anchor" id="ECL_005fBIT_005fVECTOR_005fP"></a><a class="index-entry-id" id="index-ECL_005fBIT_005fVECTOR_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fSTRINGP"></a><a class="index-entry-id" id="index-ECL_005fSTRINGP"></a>
|
|||
|
<a class="anchor" id="ECL_005fHASH_005fTABLE_005fP"></a><a class="index-entry-id" id="index-ECL_005fHASH_005fTABLE_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fRANDOM_005fSTATE_005fP"></a><a class="index-entry-id" id="index-ECL_005fRANDOM_005fSTATE_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fPACKAGEP"></a><a class="index-entry-id" id="index-ECL_005fPACKAGEP"></a>
|
|||
|
<a class="anchor" id="ECL_005fPATHNAMEP"></a><a class="index-entry-id" id="index-ECL_005fPATHNAMEP"></a>
|
|||
|
<a class="anchor" id="ECL_005fREADTABLEP"></a><a class="index-entry-id" id="index-ECL_005fREADTABLEP"></a>
|
|||
|
<a class="anchor" id="ECL_005fFOREIGN_005fDATA_005fP"></a><a class="index-entry-id" id="index-ECL_005fFOREIGN_005fDATA_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fSSE_005fPACK_005fP"></a><a class="index-entry-id" id="index-ECL_005fSSE_005fPACK_005fP"></a>
|
|||
|
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fCHARACTERP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_CHARACTERP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCHARACTERP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fBASE_005fCHAR_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_BASE_CHAR_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fBASE_005fCHAR_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fBASE_005fCHAR_005fCODE_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_BASE_CHAR_CODE_P</strong> <code class="def-code-arguments">(ecl_character o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fBASE_005fCHAR_005fCODE_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fNUMBER_005fTYPE_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_NUMBER_TYPE_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fNUMBER_005fTYPE_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCOMPLEXP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_COMPLEXP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCOMPLEXP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fREAL_005fTYPE_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_REAL_TYPE_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fREAL_005fTYPE_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fFIXNUMP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_FIXNUMP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fFIXNUMP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fBIGNUMP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_BIGNUMP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fBIGNUMP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSINGLE_005fFLOAT_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_SINGLE_FLOAT_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSINGLE_005fFLOAT_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fDOUBLE_005fFLOAT_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_DOUBLE_FLOAT_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fDOUBLE_005fFLOAT_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fLONG_005fFLOAT_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_LONG_FLOAT_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fLONG_005fFLOAT_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCONSP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_CONSP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCONSP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fLISTP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_LISTP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fLISTP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fATOM-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_ATOM</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fATOM-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSYMBOLP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_SYMBOLP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSYMBOLP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fARRAYP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_ARRAYP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fARRAYP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fVECTORP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_VECTORP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fVECTORP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fBIT_005fVECTOR_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_BIT_VECTOR_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fBIT_005fVECTOR_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSTRINGP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_STRINGP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSTRINGP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fHASH_005fTABLE_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_HASH_TABLE_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fHASH_005fTABLE_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fRANDOM_005fSTATE_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_RANDOM_STATE_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fRANDOM_005fSTATE_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fPACKAGEP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_PACKAGEP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fPACKAGEP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fPATHNAMEP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_PATHNAMEP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fPATHNAMEP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fREADTABLEP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_READTABLEP</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fREADTABLEP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fFOREIGN_005fDATA_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_FOREIGN_DATA_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fFOREIGN_005fDATA_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSSE_005fPACK_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_SSE_PACK_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSSE_005fPACK_005fP-1'> ¶</a></span></dt>
|
|||
|
<dd>
|
|||
|
<p>Different macros that check whether <var class="var">o</var> belongs to the specified
|
|||
|
type. These checks have been optimized, and are preferred over several
|
|||
|
calls to <code class="code">ecl_t_of</code>.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ECL_005fIMMEDIATE"></a><a class="index-entry-id" id="index-ECL_005fIMMEDIATE"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fIMMEDIATE-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_IMMEDIATE</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fIMMEDIATE-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Tells whether <var class="var">x</var> is an immediate datatype.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<hr>
|
|||
|
</div>
|
|||
|
<div class="subsection-level-extent" id="Constructing-objects">
|
|||
|
<div class="nav-panel">
|
|||
|
<p>
|
|||
|
Previous: <a href="Manipulating-Lisp-objects.html#Objects-representation" accesskey="p" rel="prev">Objects representation</a>, Up: <a href="Manipulating-Lisp-objects.html#Manipulating-Lisp-objects" accesskey="u" rel="up">Manipulating Lisp objects</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indexes.html" title="Index" rel="index">Index</a>]</p>
|
|||
|
</div>
|
|||
|
<h4 class="subsection" id="Constructing-objects-1">4.4.2 Constructing objects</h4>
|
|||
|
|
|||
|
<p>On each of the following sections we will document the standard
|
|||
|
interface for building objects of different types. For some objects,
|
|||
|
though, it is too difficult to make a C interface that resembles all of
|
|||
|
the functionality in the lisp environment. In those cases you need to
|
|||
|
</p>
|
|||
|
<ol class="enumerate">
|
|||
|
<li> build the objects from their textual representation, or
|
|||
|
</li><li> use the evaluator to build these objects.
|
|||
|
</li></ol>
|
|||
|
|
|||
|
<p>The first way makes use of a C or Lisp string to construct an
|
|||
|
object. The two functions you need to know are the following ones.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="c_005fstring_005fto_005fobject"></a><a class="index-entry-id" id="index-c_005fstring_005fto_005fobject"></a>
|
|||
|
<a class="anchor" id="ecl_005fread_005ffrom_005fcstring"></a><a class="index-entry-id" id="index-ecl_005fread_005ffrom_005fcstring"></a>
|
|||
|
<a class="anchor" id="si_005fstring_005fto_005fobject"></a><a class="index-entry-id" id="index-si_005fstring_005fto_005fobject"></a>
|
|||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
|||
|
<dt class="deffn defun-alias-deffn" id="index-si_003a_003astring_002dto_002dobject"><span class="category-def">Function: </span><span><strong class="def-name">si::string-to-object</strong> <var class="def-var-arguments">string &optional (err-value nil)</var><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-si_003a_003astring_002dto_002dobject'> ¶</a></span></dt>
|
|||
|
</dl>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-si_005fstring_005fto_005fobject-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">si_string_to_object</strong> <code class="def-code-arguments">(cl_narg narg, cl_object str, ...)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-si_005fstring_005fto_005fobject-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005fread_005ffrom_005fcstring-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ecl_read_from_cstring</strong> <code class="def-code-arguments">(const char *s)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fread_005ffrom_005fcstring-1'> ¶</a></span></dt>
|
|||
|
<dd><p><code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#ecl_005fread_005ffrom_005fcstring">ecl_read_from_cstring</a></code> builds a lisp object from a C string
|
|||
|
which contains a suitable representation of a lisp
|
|||
|
object. <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#si_005fstring_005fto_005fobject">si_string_to_object</a></code> performs the same task, but uses a
|
|||
|
lisp string, and therefore it is less useful.
|
|||
|
</p>
|
|||
|
<ul class="itemize mark-bullet">
|
|||
|
<li><strong class="strong">DEPRECATED</strong> <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#c_005fstring_005fto_005fobject">c_string_to_object</a></code> – equivalent to <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#ecl_005fread_005ffrom_005fcstring">ecl_read_from_cstring</a></code>
|
|||
|
</li></ul>
|
|||
|
|
|||
|
<h4 class="subsubheading" id="Example-3">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-html-constructing-Lisp-objects-in-C"></a>
|
|||
|
|
|||
|
<p>Using a C string
|
|||
|
</p><div class="example">
|
|||
|
<pre class="example-preformatted">cl_object array1 = ecl_read_from_cstring("#(1 2 3 4)");
|
|||
|
</pre></div>
|
|||
|
|
|||
|
<p>Using a Lisp string
|
|||
|
</p><div class="example">
|
|||
|
<pre class="example-preformatted">cl_object string = make_simple_base_string("#(1 2 3 4)");
|
|||
|
cl_object array2 = si_string_to_object(string);
|
|||
|
</pre></div>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Integers">Integers</h4>
|
|||
|
<p>Common-Lisp distinguishes two types of integer types: <code class="code">bignum</code>s and
|
|||
|
<code class="code">fixnum</code>s. A fixnum is a small integer, which ideally occupies only
|
|||
|
a word of memory and which is between the values
|
|||
|
<code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#MOST_002dNEGATIVE_002dFIXNUM">MOST-NEGATIVE-FIXNUM</a></code> and <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#MOST_002dPOSITIVE_002dFIXNUM">MOST-POSITIVE-FIXNUM</a></code>. A
|
|||
|
<code class="code">bignum</code> is any integer which is not a <code class="code">fixnum</code> and it is only
|
|||
|
constrained by the amount of memory available to represent it.
|
|||
|
</p>
|
|||
|
<p>In ECL a <code class="code">fixnum</code> is an integer that, together with the tag bits,
|
|||
|
fits in a word of memory. The size of a word, and thus the size of a
|
|||
|
<code class="code">fixnum</code>, varies from one architecture to another, and you should
|
|||
|
refer to the types and constants in the ecl.h header to make sure that
|
|||
|
your C extensions are portable. All other integers are stored as
|
|||
|
<code class="code">bignum</code>s, they are not immediate objects, they take up a variable
|
|||
|
amount of memory and the GNU Multiprecision Library is required to
|
|||
|
create, manipulate and calculate with them.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="cl_005ffixnum"></a><a class="index-entry-id" id="index-cl_005ffixnum"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-cl_005ffixnum-2"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">cl_fixnum</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-cl_005ffixnum-2'> ¶</a></span></dt>
|
|||
|
<dd><p>This is a C signed integer type capable of holding a whole <code class="code">fixnum</code>
|
|||
|
without any loss of precision. The opposite is not true, and you may
|
|||
|
create a <code class="code">cl_fixnum</code> which exceeds the limits of a fixnum and
|
|||
|
should be stored as a <code class="code">bignum</code>.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="cl_005findex"></a><a class="index-entry-id" id="index-cl_005findex"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-cl_005findex-2"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">cl_index</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-cl_005findex-2'> ¶</a></span></dt>
|
|||
|
<dd><p>This is a C unsigned integer type capable of holding a non-negative
|
|||
|
<code class="code">fixnum</code> without loss of precision. Typically, a <code class="code">cl_index</code> is
|
|||
|
used as an index into an array, or into a proper list, etc.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="MOST_005fNEGATIVE_005fFIXNUM"></a><a class="index-entry-id" id="index-MOST_005fNEGATIVE_005fFIXNUM"></a>
|
|||
|
<a class="anchor" id="MOST_005fPOSITIVE_005fFIXNUM"></a><a class="index-entry-id" id="index-MOST_005fPOSITIVE_005fFIXNUM"></a>
|
|||
|
<a class="anchor" id="MOST_002dNEGATIVE_002dFIXNUM"></a><a class="index-entry-id" id="index-MOST_002dNEGATIVE_002dFIXNUM"></a>
|
|||
|
<a class="anchor" id="MOST_002dPOSITIVE_002dFIXNUM"></a><a class="index-entry-id" id="index-MOST_002dPOSITIVE_002dFIXNUM"></a>
|
|||
|
<dl class="first-defvr">
|
|||
|
<dt class="defvr" id="index-MOST_005fNEGATIVE_005fFIXNUM-1"><span class="category-def">Constant: </span><span><strong class="def-name">MOST_NEGATIVE_FIXNUM</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-MOST_005fNEGATIVE_005fFIXNUM-1'> ¶</a></span></dt>
|
|||
|
<dt class="defvrx def-cmd-defvr" id="index-MOST_005fPOSITIVE_005fFIXNUM-1"><span class="category-def">Constant: </span><span><strong class="def-name">MOST_POSITIVE_FIXNUM</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-MOST_005fPOSITIVE_005fFIXNUM-1'> ¶</a></span></dt>
|
|||
|
<dd><p>These constants mark the limits of a <code class="code">fixnum</code>.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005ffixnum_005flower"></a><a class="index-entry-id" id="index-ecl_005ffixnum_005flower"></a>
|
|||
|
<a class="anchor" id="ecl_005ffixnum_005fgreater"></a><a class="index-entry-id" id="index-ecl_005ffixnum_005fgreater"></a>
|
|||
|
<a class="anchor" id="ecl_005ffixnum_005fleq"></a><a class="index-entry-id" id="index-ecl_005ffixnum_005fleq"></a>
|
|||
|
<a class="anchor" id="ecl_005ffixnum_005fgeq"></a><a class="index-entry-id" id="index-ecl_005ffixnum_005fgeq"></a>
|
|||
|
<a class="anchor" id="ecl_005ffixnum_005fplusp"></a><a class="index-entry-id" id="index-ecl_005ffixnum_005fplusp"></a>
|
|||
|
<a class="anchor" id="ecl_005ffixnum_005fminusp"></a><a class="index-entry-id" id="index-ecl_005ffixnum_005fminusp"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005ffixnum_005flower-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_fixnum_lower</strong> <code class="def-code-arguments">(cl_fixnum a, cl_fixnum b)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum_005flower-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005ffixnum_005fgreater-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_fixnum_greater</strong> <code class="def-code-arguments">(cl_fixnum a, cl_fixnum b)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum_005fgreater-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005ffixnum_005fleq-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_fixnum_leq</strong> <code class="def-code-arguments">(cl_fixnum a, cl_fixnum b)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum_005fleq-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005ffixnum_005fgeq-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_fixnum_geq</strong> <code class="def-code-arguments">(cl_fixnum a, cl_fixnum b)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum_005fgeq-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005ffixnum_005fplusp-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_fixnum_plusp</strong> <code class="def-code-arguments">(cl_fixnum a)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum_005fplusp-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005ffixnum_005fminusp-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_fixnum_minusp</strong> <code class="def-code-arguments">(cl_fixnum a)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum_005fminusp-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Operations on <code class="code">fixnums</code> (comparison and predicates).
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-ecl_005fmake_005ffixnum-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ecl_005ffixnum-1"></a>
|
|||
|
<a class="index-entry-id" id="index-MAKE_005fFIXNUM"></a>
|
|||
|
<a class="index-entry-id" id="index-fix"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005fmake_005ffixnum-3"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ecl_make_fixnum</strong> <code class="def-code-arguments">(cl_fixnum n)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fmake_005ffixnum-3'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005ffixnum-3"><span class="category-def">Function: </span><span><code class="def-type">cl_fixnum</code> <strong class="def-name">ecl_fixnum</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffixnum-3'> ¶</a></span></dt>
|
|||
|
<dd><p><code class="code">ecl_make_fixnum</code> converts from an integer to a lisp object, while
|
|||
|
the <code class="code">ecl_fixnum</code> does the opposite (converts lisp object fixnum to
|
|||
|
integer). These functions do <strong class="strong">not</strong> check their arguments.
|
|||
|
</p><ul class="itemize mark-bullet">
|
|||
|
<li><strong class="strong">DEPRECATED</strong> <code class="code">MAKE_FIXNUM</code> – equivalent to <code class="code">ecl_make_fixnum</code>
|
|||
|
</li><li><strong class="strong">DEPRECATED</strong> <code class="code">fix</code> – equivalent to <code class="code">ecl_fixnum</code>
|
|||
|
</li></ul>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-cl_005ffixnum-1"></a>
|
|||
|
<a class="index-entry-id" id="index-cl_005findex-1"></a>
|
|||
|
<a class="anchor" id="fixint"></a><a class="index-entry-id" id="index-fixint"></a>
|
|||
|
<a class="anchor" id="fixnint"></a><a class="index-entry-id" id="index-fixnint"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-fixint-1"><span class="category-def">Function: </span><span><code class="def-type">cl_fixnum</code> <strong class="def-name">fixint</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-fixint-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-fixnint-1"><span class="category-def">Function: </span><span><code class="def-type">cl_index</code> <strong class="def-name">fixnint</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-fixnint-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Safe conversion of a lisp <code class="code">fixnum</code> to a C integer of the
|
|||
|
appropriate size. Signals an error if <var class="var">o</var> is not of fixnum type.
|
|||
|
</p>
|
|||
|
<p><code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#fixnint">fixnint</a></code> additionally ensure that <var class="var">o</var> is not negative.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Characters-2">Characters</h4>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-_002d_002denable_002dunicode-_005b32_007c16_007cno_005d-1"></a>
|
|||
|
|
|||
|
<p>ECL has two types of characters – one fits in the C type char, while
|
|||
|
the other is used when ECL is built with a configure option
|
|||
|
<code class="code">--enable-unicode</code> which defaults to 32 (characters are stored in
|
|||
|
32bit variable and codepoints have 21-bits).
|
|||
|
</p>
|
|||
|
<a class="index-entry-id" id="index-ecl_005fcharacter-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ecl_005fbase_005fchar-1"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-ecl_005fcharacter-2"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_character</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fcharacter-2'> ¶</a></span></dt>
|
|||
|
<dd><p>Immediate type <code class="code">t_character</code>. If ECL built with Unicode support,
|
|||
|
then may be either base or extended character, which may be
|
|||
|
distinguished with the predicate <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#ECL_005fBASE_005fCHAR_005fP">ECL_BASE_CHAR_P</a></code>.
|
|||
|
</p>
|
|||
|
<p>Additionally we have <code class="code"><a class="ref" href="Characters.html#ecl_005fbase_005fchar">ecl_base_char</a></code> for base strings, which is an
|
|||
|
equivalent to the ordinary char.
|
|||
|
</p>
|
|||
|
<h4 class="subsubheading" id="Example-4">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-distinguishing-between-base-and-Unicode-character"></a>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">if (ECL_CHARACTERP(o) && ECL_BASE_CHAR_P(o))
|
|||
|
printf("Base character: %c\n", ECL_CHAR_CODE(o));
|
|||
|
</pre></div>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-ECL_005fCHAR_005fCODE_005fLIMIT"></a>
|
|||
|
<a class="index-entry-id" id="index-CHAR_005fCODE_005fLIMIT"></a>
|
|||
|
<dl class="first-defvr">
|
|||
|
<dt class="defvr" id="index-ECL_005fCHAR_005fCODE_005fLIMIT-1"><span class="category-def">Constant: </span><span><strong class="def-name">ECL_CHAR_CODE_LIMIT</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCHAR_005fCODE_005fLIMIT-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Each character is assigned an integer code which ranges from 0 to
|
|||
|
(ECL_CHAR_CODE_LIMIT-1).
|
|||
|
</p><ul class="itemize mark-bullet">
|
|||
|
<li><strong class="strong">DEPRECATED</strong> <code class="code">CHAR_CODE_LIMIT</code> – equivalent to <code class="code">ECL_CHAR_CODE_LIMIT</code>
|
|||
|
</li></ul>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-ecl_005fchar_005fcode-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ecl_005fbase_005fchar_005fcode-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ECL_005fCHAR_005fCODE-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ECL_005fCODE_005fCHAR-1"></a>
|
|||
|
<a class="index-entry-id" id="index-CODE_005fCHAR"></a>
|
|||
|
<a class="index-entry-id" id="index-CHAR_005fCODE"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fCODE_005fCHAR-3"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CODE_CHAR</strong> <code class="def-code-arguments">(ecl_character o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCODE_005fCHAR-3'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCHAR_005fCODE-3"><span class="category-def">Function: </span><span><code class="def-type">ecl_character</code> <strong class="def-name">ECL_CHAR_CODE</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCHAR_005fCODE-3'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005fchar_005fcode-3"><span class="category-def">Function: </span><span><code class="def-type">ecl_character</code> <strong class="def-name">ecl_char_code</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fchar_005fcode-3'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005fbase_005fchar_005fcode-3"><span class="category-def">Function: </span><span><code class="def-type">ecl_base_char</code> <strong class="def-name">ecl_base_char_code</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fbase_005fchar_005fcode-3'> ¶</a></span></dt>
|
|||
|
<dd><p><code class="code">ECL_CHAR_CODE</code>, <code class="code">ecl_char_code</code> and
|
|||
|
<code class="code">ecl_base_char_code</code> return the integer code associated to a
|
|||
|
lisp character. <code class="code">ecl_char_code</code> and <code class="code">ecl_base_char_code</code>
|
|||
|
perform a safe conversion, while <code class="code">ECL_CHAR_CODE</code> doesn’t check
|
|||
|
its argument.
|
|||
|
</p>
|
|||
|
<p><code class="code">ECL_CODE_CHAR</code> returns the lisp character associated to an integer
|
|||
|
code. It does not check its arguments.
|
|||
|
</p>
|
|||
|
<ul class="itemize mark-bullet">
|
|||
|
<li><strong class="strong">DEPRECATED</strong> <code class="code">CHAR_CODE</code> – equivalent to <code class="code">ECL_CHAR_CODE</code>
|
|||
|
</li><li><strong class="strong">DEPRECATED</strong> <code class="code">CODE_CHAR</code> – equivalent to <code class="code">ECL_CODE_CHAR</code>
|
|||
|
</li></ul>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005fchar_005feq"></a><a class="index-entry-id" id="index-ecl_005fchar_005feq"></a>
|
|||
|
<a class="anchor" id="ecl_005fchar_005fequal"></a><a class="index-entry-id" id="index-ecl_005fchar_005fequal"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005fchar_005feq-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_char_eq</strong> <code class="def-code-arguments">(cl_object x, cl_object y)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fchar_005feq-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005fchar_005fequal-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ecl_char_equal</strong> <code class="def-code-arguments">(cl_object x, cl_object y)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fchar_005fequal-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Compare two characters for equality. char_eq take case into account and
|
|||
|
char_equal ignores it.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005fchar_005fcmp"></a><a class="index-entry-id" id="index-ecl_005fchar_005fcmp"></a>
|
|||
|
<a class="anchor" id="ecl_005fchar_005fcompare"></a><a class="index-entry-id" id="index-ecl_005fchar_005fcompare"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005fchar_005fcmp-1"><span class="category-def">Function: </span><span><code class="def-type">int</code> <strong class="def-name">ecl_char_cmp</strong> <code class="def-code-arguments">(cl_object x, cl_object y)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fchar_005fcmp-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005fchar_005fcompare-1"><span class="category-def">Function: </span><span><code class="def-type">int</code> <strong class="def-name">ecl_char_compare</strong> <code class="def-code-arguments">(cl_object x, cl_object y)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fchar_005fcompare-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Compare the relative order of two characters. <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#ecl_005fchar_005fcmp">ecl_char_cmp</a></code>
|
|||
|
takes care of case and <code class="code"><a class="ref" href="Manipulating-Lisp-objects.html#ecl_005fchar_005fcompare">ecl_char_compare</a></code> converts all
|
|||
|
characters to uppercase before comparing them.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Arrays-2">Arrays</h4>
|
|||
|
|
|||
|
<p>An array is an aggregate of data of a common type, which can be accessed
|
|||
|
with one or more non-negative indices. ECL stores arrays as a C structure
|
|||
|
with a pointer to the region of memory which contains the actual
|
|||
|
data. The cell of an array datatype varies depending on whether it is a
|
|||
|
vector, a bit-vector, a multidimensional array or a string.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="ECL_005fADJUSTABLE_005fARRAY_005fP"></a><a class="index-entry-id" id="index-ECL_005fADJUSTABLE_005fARRAY_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fARRAY_005fHAS_005fFILL_005fPOINTER_005fP"></a><a class="index-entry-id" id="index-ECL_005fARRAY_005fHAS_005fFILL_005fPOINTER_005fP"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fADJUSTABLE_005fARRAY_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_ADJUSTABLE_ARRAY_P</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fADJUSTABLE_005fARRAY_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fARRAY_005fHAS_005fFILL_005fPOINTER_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_ARRAY_HAS_FILL_POINTER_P</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fARRAY_005fHAS_005fFILL_005fPOINTER_005fP-1'> ¶</a></span></dt>
|
|||
|
<dd><p>All arrays (arrays, strings and bit-vectors) may be tested for being
|
|||
|
adjustable and whenever they have a fill pointer with this two
|
|||
|
macros. They don’t check the type of their arguments.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005fvector"></a><a class="index-entry-id" id="index-ecl_005fvector"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-ecl_005fvector-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_vector</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fvector-1'> ¶</a></span></dt>
|
|||
|
<dd><p>If <code class="code">x</code> contains a vector, you can access the following fields:
|
|||
|
</p>
|
|||
|
<dl class="table">
|
|||
|
<dt><code class="code">x->vector.elttype</code></dt>
|
|||
|
<dd><p>The type of the elements of the vector.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->vector.displaced</code></dt>
|
|||
|
<dd><p>List storing the vectors that <code class="code">x</code> is displaced from and that x
|
|||
|
displaces to.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->vector.dim</code></dt>
|
|||
|
<dd><p>The maximum number of elements.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->vector.fillp</code></dt>
|
|||
|
<dd><p>Actual number of elements in the vector or <code class="code">fill pointer</code>.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->vector.self</code></dt>
|
|||
|
<dd><p>Union of pointers of different types. You should choose the right
|
|||
|
pointer depending on <var class="var">x->vector.elttype</var>.
|
|||
|
</p></dd>
|
|||
|
</dl>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005farray"></a><a class="index-entry-id" id="index-ecl_005farray"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-ecl_005farray-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_array</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005farray-1'> ¶</a></span></dt>
|
|||
|
<dd><p>If <code class="code">x</code> contains a multidimensional array, you can access the
|
|||
|
following fields:
|
|||
|
</p>
|
|||
|
<dl class="table">
|
|||
|
<dt><code class="code">x->array.elttype</code></dt>
|
|||
|
<dd><p>The type of the elements of the array.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->array.rank</code></dt>
|
|||
|
<dd><p>The number of array dimensions.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->array.displaced</code></dt>
|
|||
|
<dd><p>List storing the arrays that <code class="code">x</code> is displaced from and that x
|
|||
|
displaces to.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->array.dim</code></dt>
|
|||
|
<dd><p>The maximum number of elements.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->array.dims[]</code></dt>
|
|||
|
<dd><p>Array with the dimensions of the array. The elements range from
|
|||
|
<code class="code">x->array.dim[0]</code> to <code class="code">x->array.dim[x->array.rank-1]</code>.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->array.fillp</code></dt>
|
|||
|
<dd><p>Actual number of elements in the array or <code class="code">fill pointer</code>.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->array.self</code></dt>
|
|||
|
<dd><p>Union of pointers of different types. You should choose the right
|
|||
|
pointer depending on <var class="var">x->array.elttype</var>.
|
|||
|
</p></dd>
|
|||
|
</dl>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-cl_005felttype-1"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-cl_005felttype-3"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">cl_elttype</strong> <var class="def-var-arguments">ecl_aet_object ecl_aet_sf ecl_aet_df ecl_aet_lf ecl_aet_csf ecl_aet_cdf ecl_aet_clf ecl_aet_bit ecl_aet_fix ecl_aet_index ecl_aet_b8 ecl_aet_i8 ecl_aet_b16 ecl_aet_i16 ecl_aet_b32 ecl_aet_i32 ecl_aet_b64 ecl_aet_i64 ecl_aet_ch ecl_aet_bc</var><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-cl_005felttype-3'> ¶</a></span></dt>
|
|||
|
<dd>
|
|||
|
<p>Each array is of an specialized type which is the type of the elements
|
|||
|
of the array. ECL has arrays only a few following specialized types, and
|
|||
|
for each of these types there is a C integer which is the corresponding
|
|||
|
value of <code class="code">x->array.elttype</code> or <code class="code">x->vector.elttype</code>. We list
|
|||
|
some of those types together with the C constant that denotes that type:
|
|||
|
</p>
|
|||
|
<dl class="table">
|
|||
|
<dt><var class="var">t</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_object</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">single-float</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_sf</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">double-float</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_df</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">long-float</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_lf</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">(COMPLEX SINGLE-FLOAT)</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_csf</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">(COMPLEX DOUBLE-FLOAT)</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_cdf</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">(COMPLEX LONG-FLOAT)</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_clf</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">BIT</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_bit</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">FIXNUM</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_fix</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">INDEX</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_index</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">CHARACTER</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_ch</code>
|
|||
|
</p></dd>
|
|||
|
<dt><var class="var">BASE-CHAR</var></dt>
|
|||
|
<dd><p><code class="code">ecl_aet_bc</code>
|
|||
|
</p></dd>
|
|||
|
</dl>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-ecl_005farray_005felttype-1"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005farray_005felttype-3"><span class="category-def">Function: </span><span><code class="def-type">cl_elttype</code> <strong class="def-name">ecl_array_elttype</strong> <code class="def-code-arguments">(cl_object array)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005farray_005felttype-3'> ¶</a></span></dt>
|
|||
|
<dd><p>Returns the element type of the array <code class="code">o</code>, which can be a string, a
|
|||
|
bit-vector, vector, or a multidimensional array.
|
|||
|
</p>
|
|||
|
<h4 class="subsubheading" id="Example-5">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-ecl_005farray_005felttype-different-types-of-objects"></a>
|
|||
|
<p>For example, the code
|
|||
|
</p>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">ecl_array_elttype(ecl_read_from_cstring("\"AAA\"")); /* returns ecl_aet_ch */
|
|||
|
ecl_array_elttype(ecl_read_from_cstring("#(A B C)")); /* returns ecl_aet_object */
|
|||
|
</pre></div>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-ecl_005faref-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ecl_005faset-1"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005faref-3"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ecl_aref</strong> <code class="def-code-arguments">(cl_object x, cl_index index)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005faref-3'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005faset-3"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ecl_aset</strong> <code class="def-code-arguments">(cl_object x, cl_index index, cl_object value)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005faset-3'> ¶</a></span></dt>
|
|||
|
<dd><p>These functions are used to retrieve and set the elements of an
|
|||
|
array. The elements are accessed with one index, index, as in the lisp
|
|||
|
function ROW-MAJOR-AREF.
|
|||
|
</p>
|
|||
|
<h4 class="subsubheading" id="Example-6">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-ecl_005faref-and-ecl_005faset-accessing-arrays"></a>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">cl_object array = ecl_read_from_cstring("#2A((1 2) (3 4))");
|
|||
|
cl_object x = ecl_aref(array, 3);
|
|||
|
cl_print(1, x); /* Outputs 4 */
|
|||
|
ecl_aset(array, 3, ecl_make_fixnum(5));
|
|||
|
cl_print(1, array); /* Outputs #2A((1 2) (3 5)) */
|
|||
|
</pre></div>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="index-entry-id" id="index-ecl_005faref1-1"></a>
|
|||
|
<a class="index-entry-id" id="index-ecl_005faset1-1"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ecl_005faref1-3"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ecl_aref1</strong> <code class="def-code-arguments">(cl_object x, cl_index index)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005faref1-3'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ecl_005faset1-3"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ecl_aset1</strong> <code class="def-code-arguments">(cl_object x, cl_index index, cl_object value)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005faset1-3'> ¶</a></span></dt>
|
|||
|
<dd><p>These functions are similar to <code class="code">aref</code> and <code class="code">aset</code>, but they operate on vectors.
|
|||
|
</p>
|
|||
|
<h4 class="subsubheading" id="Example-7">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-ecl_005faref1-and-ecl_005faset1-accessing-vectors"></a>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">cl_object array = ecl_read_from_cstring("#(1 2 3 4)");
|
|||
|
cl_object x = ecl_aref1(array, 3);
|
|||
|
cl_print(1, x); /* Outputs 4 */
|
|||
|
ecl_aset1(array, 3, ecl_make_fixnum(5));
|
|||
|
cl_print(1, array); /* Outputs #(1 2 3 5) */
|
|||
|
</pre></div>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Strings-2">Strings</h4>
|
|||
|
|
|||
|
<p>A string, both in Common-Lisp and in ECL is nothing but a vector of
|
|||
|
characters. Therefore, almost everything mentioned in the section of
|
|||
|
arrays remains valid here.
|
|||
|
</p>
|
|||
|
<p>The only important difference is that ECL stores the base-strings
|
|||
|
(non-Unicode version of a string) as a lisp object with a pointer to a
|
|||
|
zero terminated C string. Thus, if a string has n characters, ECL will
|
|||
|
reserve n+1 bytes for the base-string. This allows us to pass the
|
|||
|
base-string self pointer to any C routine.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="ecl_005fstring"></a><a class="index-entry-id" id="index-ecl_005fstring"></a>
|
|||
|
<a class="anchor" id="ecl_005fbase_005fstring"></a><a class="index-entry-id" id="index-ecl_005fbase_005fstring"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-ecl_005fstring-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_string</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fstring-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftpx def-cmd-deftp" id="index-ecl_005fbase_005fstring-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_base_string</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fbase_005fstring-1'> ¶</a></span></dt>
|
|||
|
<dd><p>If <code class="code">x</code> is a lisp object of type string or a base-string, we can
|
|||
|
access the following fields:
|
|||
|
</p><dl class="table">
|
|||
|
<dt><code class="code">x->string.dim x->base_string.dim</code></dt>
|
|||
|
<dd><p>Actual number of characters in the string.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->string.fillp x->base_string.fillp</code></dt>
|
|||
|
<dd><p>Actual number of characters in the string.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">x->string.self x->base_string.self</code></dt>
|
|||
|
<dd><p>Pointer to the characters (appropriately <code class="code">ecl_character</code>’s and <code class="code">ecl_base_char</code>’s).
|
|||
|
</p></dd>
|
|||
|
</dl>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ECL_005fEXTENDED_005fSTRING_005fP"></a><a class="index-entry-id" id="index-ECL_005fEXTENDED_005fSTRING_005fP"></a>
|
|||
|
<a class="anchor" id="ECL_005fBASE_005fSTRING_005fP"></a><a class="index-entry-id" id="index-ECL_005fBASE_005fSTRING_005fP"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fEXTENDED_005fSTRING_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_EXTENDED_STRING_P</strong> <code class="def-code-arguments">(cl_object object)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fEXTENDED_005fSTRING_005fP-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fBASE_005fSTRING_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_BASE_STRING_P</strong> <code class="def-code-arguments">(cl_object object)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fBASE_005fSTRING_005fP-1'> ¶</a></span></dt>
|
|||
|
<dd>
|
|||
|
<p>Verifies if an objects is an extended or base string. If Unicode isn’t
|
|||
|
supported, then <code class="code">ECL_EXTENDED_STRING_P</code> always returns 0.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Bit_002dvectors">Bit-vectors</h4>
|
|||
|
|
|||
|
<p>Bit-vector operations are implemented in file
|
|||
|
<code class="code">src/c/array.d</code>. Bit-vector shares the structure with a vector,
|
|||
|
therefore, almost everything mentioned in the section of arrays remains
|
|||
|
valid here.
|
|||
|
</p>
|
|||
|
<h4 class="subheading" id="Streams-2">Streams</h4>
|
|||
|
|
|||
|
<p>Streams implementation is a broad topic. Most of the implementation is
|
|||
|
done in the file <code class="code">src/c/file.d</code>. Stream handling may have different
|
|||
|
implementations referred by a member pointer <code class="code">ops</code>.
|
|||
|
</p>
|
|||
|
<p>Additionally on top of that we have implemented <em class="emph">Gray Streams</em> (in
|
|||
|
portable Common Lisp) in file <code class="code">src/clos/streams.lsp</code>, which may be
|
|||
|
somewhat slower (we need to benchmark it!). This implementation is in a
|
|||
|
separate package <var class="var">GRAY</var>. We may redefine functions in the
|
|||
|
<var class="var">COMMON-LISP</var> package with a function <code class="code">redefine-cl-functions</code>
|
|||
|
at run-time.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="ecl_005ffile_005fpos"></a><a class="index-entry-id" id="index-ecl_005ffile_005fpos"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-ecl_005ffile_005fops"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_file_ops</strong> <var class="def-var-arguments">write_* read_* unread_* peek_* listen clear_input clear_output finish_output force_output input_p output_p interactive_p element_type length get_position set_position column close</var><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005ffile_005fops'> ¶</a></span></dt>
|
|||
|
</dl>
|
|||
|
|
|||
|
<a class="anchor" id="ecl_005fstream"></a><a class="index-entry-id" id="index-ecl_005fstream"></a>
|
|||
|
<dl class="first-deftp">
|
|||
|
<dt class="deftp" id="index-ecl_005fstream-1"><span class="category-def">C/C++ identifier: </span><span><strong class="def-name">ecl_stream</strong><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ecl_005fstream-1'> ¶</a></span></dt>
|
|||
|
<dd><dl class="table">
|
|||
|
<dt><code class="code">ecl_smmode mode</code></dt>
|
|||
|
<dd><p>Stream mode (in example <code class="code">ecl_smm_string_input</code>).
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">int closed</code></dt>
|
|||
|
<dd><p>Whenever stream is closed or not.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">ecl_file_ops *ops</code></dt>
|
|||
|
<dd><p>Pointer to the structure containing operation implementations (dispatch
|
|||
|
table).
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">union file</code></dt>
|
|||
|
<dd><p>Union of ANSI C streams (FILE *stream) and POSIX files interface
|
|||
|
(cl_fixnum descriptor).
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_object object0, object1</code></dt>
|
|||
|
<dd><p>Some objects (may be used for a specific implementation purposes).
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_object byte_stack</code></dt>
|
|||
|
<dd><p>Buffer for unread bytes.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_index column</code></dt>
|
|||
|
<dd><p>File column.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_fixnum last_char</code></dt>
|
|||
|
<dd><p>Last character read.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_fixnum last_code[2]</code></dt>
|
|||
|
<dd><p>Actual composition of the last character.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_fixnum int0 int1</code></dt>
|
|||
|
<dd><p>Some integers (may be used for a specific implementation purposes).
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_index byte_size</code></dt>
|
|||
|
<dd><p>Size of byte in binary streams.
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_fixnum last_op</code></dt>
|
|||
|
<dd><p>0: unknown, 1: reading, -1: writing
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">char *buffer</code></dt>
|
|||
|
<dd><p>Buffer for FILE
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_object format</code></dt>
|
|||
|
<dd><p>external format
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">cl_eformat_encoder encoder</code></dt>
|
|||
|
<dt><code class="code">cl_eformat_encoder decoder</code></dt>
|
|||
|
<dt><code class="code">cl_object format_table</code></dt>
|
|||
|
<dt><code class="code">in flags</code></dt>
|
|||
|
<dd><p>Character table, flags, etc
|
|||
|
</p></dd>
|
|||
|
<dt><code class="code">ecl_character eof_character</code></dt>
|
|||
|
</dl>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ECL_005fANSI_005fSTREAM_005fP"></a><a class="index-entry-id" id="index-ECL_005fANSI_005fSTREAM_005fP"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fANSI_005fSTREAM_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_ANSI_STREAM_P</strong> <code class="def-code-arguments">(cl_object o)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fANSI_005fSTREAM_005fP-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Predicate determining if <code class="code">o</code> is a first-class stream object.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="ECL_005fANSI_005fSTREAM_005fTYPE_005fP"></a><a class="index-entry-id" id="index-ECL_005fANSI_005fSTREAM_005fTYPE_005fP"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fANSI_005fSTREAM_005fTYPE_005fP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_ANSI_STREAM_TYPE_P</strong> <code class="def-code-arguments">(cl_object o, ecl_smmode m)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fANSI_005fSTREAM_005fTYPE_005fP-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Predicate determining if <code class="code">o</code> is a first-class stream object of
|
|||
|
type <code class="code">m</code>.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Structures-2">Structures</h4>
|
|||
|
|
|||
|
<p>Structures and instances share the same datatype <code class="code">t_instance</code> (
|
|||
|
with a few exceptions. Structure implementation details are the file
|
|||
|
<code class="code">src/c/structure.d</code>.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="ECL_005fSTRUCT_005fTYPE"></a><a class="index-entry-id" id="index-ECL_005fSTRUCT_005fTYPE"></a>
|
|||
|
<a class="anchor" id="ECL_005fSTRUCT_005fSLOTS"></a><a class="index-entry-id" id="index-ECL_005fSTRUCT_005fSLOTS"></a>
|
|||
|
<a class="anchor" id="ECL_005fSTRUCT_005fLENGTH"></a><a class="index-entry-id" id="index-ECL_005fSTRUCT_005fLENGTH"></a>
|
|||
|
<a class="anchor" id="ECL_005fSTRUCT_005fSLOT"></a><a class="index-entry-id" id="index-ECL_005fSTRUCT_005fSLOT"></a>
|
|||
|
<a class="anchor" id="ECL_005fSTRUCT_005fNAME"></a><a class="index-entry-id" id="index-ECL_005fSTRUCT_005fNAME"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fSTRUCT_005fTYPE-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_STRUCT_TYPE</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSTRUCT_005fTYPE-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSTRUCT_005fSLOTS-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_STRUCT_SLOTS</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSTRUCT_005fSLOTS-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSTRUCT_005fLENGTH-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_STRUCT_LENGTH</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSTRUCT_005fLENGTH-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSTRUCT_005fSLOT-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_STRUCT_SLOT</strong> <code class="def-code-arguments">(cl_object x, cl_index i)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSTRUCT_005fSLOT-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSTRUCT_005fNAME-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_STRUCT_NAME</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSTRUCT_005fNAME-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Convenience functions for the structures.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Instances">Instances</h4>
|
|||
|
|
|||
|
<a class="anchor" id="ECL_005fCLASS_005fOF"></a><a class="index-entry-id" id="index-ECL_005fCLASS_005fOF"></a>
|
|||
|
<a class="anchor" id="ECL_005fSPEC_005fFLAG"></a><a class="index-entry-id" id="index-ECL_005fSPEC_005fFLAG"></a>
|
|||
|
<a class="anchor" id="ECL_005fSPEC_005fOBJECT"></a><a class="index-entry-id" id="index-ECL_005fSPEC_005fOBJECT"></a>
|
|||
|
<a class="anchor" id="ECL_005fCLASS_005fNAME"></a><a class="index-entry-id" id="index-ECL_005fCLASS_005fNAME"></a>
|
|||
|
<a class="anchor" id="ECL_005fCLASS_005fSUPERIORS"></a><a class="index-entry-id" id="index-ECL_005fCLASS_005fSUPERIORS"></a>
|
|||
|
<a class="anchor" id="ECL_005fCLASS_005fINFERIORS"></a><a class="index-entry-id" id="index-ECL_005fCLASS_005fINFERIORS"></a>
|
|||
|
<a class="anchor" id="ECL_005fCLASS_005fSLOTS"></a><a class="index-entry-id" id="index-ECL_005fCLASS_005fSLOTS"></a>
|
|||
|
<a class="anchor" id="ECL_005fCLASS_005fCPL"></a><a class="index-entry-id" id="index-ECL_005fCLASS_005fCPL"></a>
|
|||
|
<a class="anchor" id="ECL_005fINSTANCEP"></a><a class="index-entry-id" id="index-ECL_005fINSTANCEP"></a>
|
|||
|
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-ECL_005fCLASS_005fOF-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CLASS_OF</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCLASS_005fOF-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSPEC_005fFLAG-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_SPEC_FLAG</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSPEC_005fFLAG-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fSPEC_005fOBJECT-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_SPEC_OBJECT</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fSPEC_005fOBJECT-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCLASS_005fNAME-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CLASS_NAME</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCLASS_005fNAME-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCLASS_005fSUPERIORS-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CLASS_SUPERIORS</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCLASS_005fSUPERIORS-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCLASS_005fINFERIORS-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CLASS_INFERIORS</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCLASS_005fINFERIORS-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCLASS_005fSLOTS-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CLASS_SLOTS</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCLASS_005fSLOTS-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fCLASS_005fCPL-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">ECL_CLASS_CPL</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fCLASS_005fCPL-1'> ¶</a></span></dt>
|
|||
|
<dt class="deftypefnx deftypefunx-alias-deftypefnx def-cmd-deftypefn" id="index-ECL_005fINSTANCEP-1"><span class="category-def">Function: </span><span><code class="def-type">bool</code> <strong class="def-name">ECL_INSTANCEP</strong> <code class="def-code-arguments">(cl_object x)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-ECL_005fINSTANCEP-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Convenience functions for the structures.
|
|||
|
</p></dd></dl>
|
|||
|
|
|||
|
<h4 class="subheading" id="Bytecodes">Bytecodes</h4>
|
|||
|
|
|||
|
<p>A bytecodes object is a lisp object with a piece of code that can be
|
|||
|
interpreted. The objects of type <code class="code">t_bytecodes</code> are implicitly
|
|||
|
constructed by a call to eval, but can also be explicitly constructed
|
|||
|
with the <code class="code">si_make_lambda</code> function.
|
|||
|
</p>
|
|||
|
<a class="anchor" id="si_005fsafe_005feval"></a><a class="index-entry-id" id="index-si_005fsafe_005feval"></a>
|
|||
|
<a class="anchor" id="cl_005fsafe_005feval"></a><a class="index-entry-id" id="index-cl_005fsafe_005feval"></a>
|
|||
|
<a class="anchor" id="cl_005feval"></a><a class="index-entry-id" id="index-cl_005feval"></a>
|
|||
|
<dl class="first-deffn first-defun-alias-first-deffn">
|
|||
|
<dt class="deffn defun-alias-deffn" id="index-si_003asafe_002deval"><span class="category-def">Function: </span><span><strong class="def-name">si:safe-eval</strong> <var class="def-var-arguments">form env &optional err-value</var><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-si_003asafe_002deval'> ¶</a></span></dt>
|
|||
|
</dl>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-si_005fsafe_005feval-2"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">si_safe_eval</strong> <code class="def-code-arguments">(cl_narg narg, cl_object form, cl_object env, ...)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-si_005fsafe_005feval-2'> ¶</a></span></dt>
|
|||
|
<dd>
|
|||
|
<p><code class="code">si_safe_eval</code> evaluates <code class="code">form</code> in the lexical
|
|||
|
environment<a class="footnote" id="DOCF5" href="Manipulating-Lisp-objects.html#FOOT5"><sup>5</sup></a> <code class="code">env</code>, which can be <code class="code">ECL_NIL</code>. Before
|
|||
|
evaluating it, the expression form is bytecompiled. If the form
|
|||
|
signals an error, or tries to jump to an outer point, the function has
|
|||
|
two choices: by default, it will invoke a debugger, but if a third
|
|||
|
value is supplied, then <code class="code">si_safe_eval</code> will not use a debugger
|
|||
|
but rather return that value.
|
|||
|
</p>
|
|||
|
<ul class="itemize mark-bullet">
|
|||
|
<li><strong class="strong">DEPRECATED</strong> <code class="code">cl_object cl_eval (cl_object form)</code> -
|
|||
|
<code class="code">cl_eval</code> is the equivalent of <code class="code">si_safe_eval</code> but without
|
|||
|
environment and with no <code class="code">err-value</code> supplied. It exists only for
|
|||
|
compatibility with previous versions.
|
|||
|
</li><li><strong class="strong">DEPRECATED</strong> <code class="code">cl_object cl_safe_eval (cl_object form, cl_object env, cl_object err_value)</code> -
|
|||
|
Equivalent of <code class="code">si_safe_eval</code>.
|
|||
|
</li></ul>
|
|||
|
|
|||
|
<h4 class="subheading" id="Example-8">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-si_005fsafe_005feval-1"></a>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">cl_object form = ecl_read_from_cstring("(print 1)");
|
|||
|
si_safe_eval(2, form, ECL_NIL);
|
|||
|
si_safe_eval(3, form, ECL_NIL, ecl_make_fixnum(3)); /* on error function will return 3 */
|
|||
|
</pre></div>
|
|||
|
</dd></dl>
|
|||
|
|
|||
|
<a class="anchor" id="si_005fmake_005flambda"></a><a class="index-entry-id" id="index-si_005fmake_005flambda"></a>
|
|||
|
<dl class="first-deftypefn first-deftypefun-alias-first-deftypefn">
|
|||
|
<dt class="deftypefn deftypefun-alias-deftypefn" id="index-si_005fmake_005flambda-1"><span class="category-def">Function: </span><span><code class="def-type">cl_object</code> <strong class="def-name">si_make_lambda</strong> <code class="def-code-arguments">(cl_object name, cl_object def)</code><a class="copiable-link" href='Manipulating-Lisp-objects.html#index-si_005fmake_005flambda-1'> ¶</a></span></dt>
|
|||
|
<dd><p>Builds an interpreted lisp function with name given by the symbol name
|
|||
|
and body given by <code class="code">def</code>.
|
|||
|
</p>
|
|||
|
<h4 class="subheading" id="Example-9">Example</h4>
|
|||
|
<a class="index-entry-id" id="index-si_005fmake_005flambda-building-functions"></a>
|
|||
|
|
|||
|
<p>For instance, we would achieve the equivalent of
|
|||
|
</p>
|
|||
|
<div class="example lisp">
|
|||
|
<pre class="lisp-preformatted">(funcall #'(lambda (x y)
|
|||
|
(block foo (+ x y)))
|
|||
|
1 2)
|
|||
|
</pre></div>
|
|||
|
|
|||
|
<p>with the following code
|
|||
|
</p>
|
|||
|
<div class="example">
|
|||
|
<pre class="example-preformatted">cl_object def = ecl_read_from_cstring("((x y) (+ x y))");
|
|||
|
cl_object name = ecl_make_symbol("FOO", "COMMON-LISP-USER");
|
|||
|
cl_object fun = si_make_lambda(name, def);
|
|||
|
return cl_funcall(3, fun, ecl_make_fixnum(1), ecl_make_fixnum(2));
|
|||
|
</pre></div>
|
|||
|
|
|||
|
<p>Notice that <code class="code">si_make_lambda</code> performs a bytecodes compilation of
|
|||
|
the definition and thus it may signal some errors. Such errors are not
|
|||
|
handled by the routine itself so you might consider using
|
|||
|
<code class="code">si_safe_eval</code> instead.
|
|||
|
</p></dd></dl>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="footnotes-segment">
|
|||
|
<hr>
|
|||
|
<h4 class="footnotes-heading">Footnotes</h4>
|
|||
|
|
|||
|
<h5 class="footnote-body-heading"><a id="FOOT5" href="Manipulating-Lisp-objects.html#DOCF5">(5)</a></h5>
|
|||
|
<p>Note that <code class="code">env</code> must be a lexical
|
|||
|
environment as used in the interpreter, See <a class="xref" href="The-interpreter.html#The-lexical-environment">The lexical environment</a></p>
|
|||
|
</div>
|
|||
|
<hr>
|
|||
|
<div class="nav-panel">
|
|||
|
<p>
|
|||
|
Next: <a href="Environment-implementation.html" accesskey="n" rel="next">Environment implementation</a>, Previous: <a href="Defun-preprocessor.html" accesskey="p" rel="prev">Defun preprocessor</a>, Up: <a href="Developer_0027s-guide.html" accesskey="u" rel="up">Developer’s guide</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indexes.html" title="Index" rel="index">Index</a>]</p>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</body>
|
|||
|
</html>
|