241 lines
7.7 KiB
HTML
241 lines
7.7 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>Defun preprocessor (ECL Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Defun preprocessor (ECL Manual)">
|
||
|
<meta name="keywords" content="Defun preprocessor (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="Manipulating-Lisp-objects.html#Manipulating-Lisp-objects" rel="next" title="Manipulating Lisp objects">
|
||
|
<link href="Contributing.html" rel="prev" title="Contributing">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
/* colors */
|
||
|
|
||
|
div.example {margin-left: 3.2em}
|
||
|
span.r {font-family: initial; font-weight: normal; font-style: normal}
|
||
|
@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="Defun-preprocessor">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Manipulating-Lisp-objects.html#Manipulating-Lisp-objects" accesskey="n" rel="next">Manipulating Lisp objects</a>, Previous: <a href="Contributing.html" accesskey="p" rel="prev">Contributing</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="Defun-preprocessor-1">4.3 Defun preprocessor</h3>
|
||
|
|
||
|
<a class="index-entry-id" id="index-Defun-preprocessor"></a>
|
||
|
<p>The defun preprocessor allows for convenient definition of Lisp
|
||
|
functions with optional and keyword arguments and the use of Lisp
|
||
|
symbols in ECL’s own C source code. It generates the C code necessary
|
||
|
to use optional function arguments and to access symbols in ECL’s
|
||
|
builtin symbol table.
|
||
|
</p>
|
||
|
<p>Usage:
|
||
|
</p><pre class="verbatim"> dpp [in-file [out-file]]
|
||
|
</pre>
|
||
|
<p>The file named in-file is preprocessed and the output will be
|
||
|
written to the file whose name is out-file. If in-file is "-"
|
||
|
program is read from standard input, while if out-file is "-"
|
||
|
C-program is written to standard output.
|
||
|
</p>
|
||
|
<p>The function definition:
|
||
|
</p>
|
||
|
<a class="index-entry-id" id="index-dpp_003a-function-definition"></a>
|
||
|
<div class="example">
|
||
|
<pre class="verbatim">@(defun name ({var}*
|
||
|
[&optional {var | (var [initform [svar]])}*]
|
||
|
[&rest var]
|
||
|
[&key {var |
|
||
|
({var | (keyword var)} [initform [svar]])}*
|
||
|
[&allow_other_keys]]
|
||
|
[&aux {var | (var [initform])}*])
|
||
|
|
||
|
C-declaration
|
||
|
|
||
|
@ {
|
||
|
|
||
|
C-body
|
||
|
|
||
|
} @)
|
||
|
</pre></div>
|
||
|
|
||
|
<p>name is the name of the lisp function
|
||
|
</p>
|
||
|
<p>&optional may be abbreviated as &o.<br>
|
||
|
&rest may be abbreviated as &r.<br>
|
||
|
&key may be abbreviated as &k.<br>
|
||
|
&allow_other_keys may be abbreviated as &aok.<br>
|
||
|
&aux may be abbreviated as &a.
|
||
|
</p>
|
||
|
<p>Each variable becomes a C variable.
|
||
|
</p>
|
||
|
<p>Each supplied-p parameter becomes a boolean C variable.
|
||
|
</p>
|
||
|
<p>Initforms are C expressions.
|
||
|
If an expression contains non-alphanumeric characters,
|
||
|
it should be surrounded by backquotes (‘).
|
||
|
</p>
|
||
|
|
||
|
<p>Function return:
|
||
|
</p><div class="example">
|
||
|
<pre class="verbatim"> @(return {form}*);
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Return function expands into a lexical block <code class="code">{}</code>, so if it’s
|
||
|
used inside <code class="code">if/else</code>, then it should be enclosed, even if we
|
||
|
use sole <code class="code">@(return);</code>, because ";" will be treated as the next
|
||
|
instruction.
|
||
|
</p>
|
||
|
<p>Symbols:
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="verbatim">@'name'
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Expands into a C statement, whole value is the given symbol
|
||
|
from <samp class="file">symbols_list.h</samp>
|
||
|
</p>
|
||
|
<div class="example">
|
||
|
<pre class="verbatim">@[name]
|
||
|
</pre></div>
|
||
|
|
||
|
<p>Expands into a C statement, whole value is a fixnum corresponding to the
|
||
|
index in the builtin symbols table of the given symbol from
|
||
|
<samp class="file">symbols_list.h</samp>. Used for handling type errors.
|
||
|
</p></div>
|
||
|
<hr>
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="Manipulating-Lisp-objects.html#Manipulating-Lisp-objects" accesskey="n" rel="next">Manipulating Lisp objects</a>, Previous: <a href="Contributing.html" accesskey="p" rel="prev">Contributing</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>
|