72 lines
4.6 KiB
HTML
72 lines
4.6 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE>A.3.3. Defining New Series Functions</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Defining New Series Functions">
|
||
|
<meta name="keywords" value="clm">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<b>Common Lisp the Language, 2nd Edition</b>
|
||
|
<BR> <HR><A NAME=tex2html6190 HREF="node360.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html6188 HREF="node356.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html6182 HREF="node358.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html6192 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html6193 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html6191 HREF="node360.html"> Declarations</A>
|
||
|
<B>Up:</B> <A NAME=tex2html6189 HREF="node356.html"> Optimization</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html6183 HREF="node358.html"> Constraint Cycles</A>
|
||
|
<HR> <P>
|
||
|
<H2><A NAME=SECTION003433000000000000000>A.3.3. Defining New Series Functions</A></H2>
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
New functions operating on series can be defined just as easily as new
|
||
|
functions operating on any other data type. However, expressions
|
||
|
containing these new functions cannot be transformed into loops unless a
|
||
|
complete analysis of the functions is available. Among other things,
|
||
|
this implies that the definition of a new series function must appear
|
||
|
before its first use.
|
||
|
<P>
|
||
|
<BR><b>[Declaration specifier]</b><BR>
|
||
|
<tt>optimizable-series-function</tt><P>The declaration specifier <tt>(optimizable-series-function <i>integer</i>)</tt> indicates
|
||
|
that the function being defined is a series function that needs to be
|
||
|
analyzed so that it can be optimized when it appears in series expressions.
|
||
|
(A warning is issued if the function being defined neither takes a series
|
||
|
as input nor produces a series as output.) <i>Integer</i> (default 1)
|
||
|
specifies the number of values returned by the function being defined.
|
||
|
(This cannot necessarily be determined by local analysis.) The only place
|
||
|
<tt>optimizable-series-function</tt> is allowed to appear is in a declaration
|
||
|
immediately inside a <tt>defun</tt>. As an example, the following shows how a
|
||
|
simplified version of <tt>collect-sum</tt> could be defined.
|
||
|
<P><pre>
|
||
|
(defun simple-collect-sum (numbers)
|
||
|
(declare (optimizable-series-function 1))
|
||
|
(collect-fn 'number #'(lambda () 0) #'+ numbers))
|
||
|
</pre><P>
|
||
|
<P>
|
||
|
<BR><b>[Declaration specifier]</b><BR>
|
||
|
<tt>off-line-port</tt><P>The declaration specifier
|
||
|
<tt>(off-line-port <i>port-spec1</i> <i>port-spec2</i> ...)</tt> specifies that the
|
||
|
indicated inputs and outputs are off-line. This declaration
|
||
|
specifier is only allowed in a <tt>defun</tt> that contains the declaration
|
||
|
<tt>optimizable-series-function</tt>. Each <i>port-spec</i> must either be a symbol
|
||
|
that is one of the inputs of the function or an integer <i>j</i> indicating the
|
||
|
<i>j</i>th output (counting from zero). For example, <tt>(off-line-port x 1)</tt>
|
||
|
indicates that the input <tt>x</tt> and the second output are off-line.
|
||
|
Every port that is not mentioned in an <tt>off-line-port</tt>
|
||
|
declaration is assumed to be on-line. A warning is issued whenever a
|
||
|
port's actual on-line/off-line status does not agree with its declared
|
||
|
status. This makes it easier to keep track of which ports are off-line and
|
||
|
which are not. Note that off-line ports virtually never arise when
|
||
|
defining scanners or reducers.
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<BR> <HR><A NAME=tex2html6190 HREF="node360.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html6188 HREF="node356.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html6182 HREF="node358.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html6192 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html6193 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html6191 HREF="node360.html"> Declarations</A>
|
||
|
<B>Up:</B> <A NAME=tex2html6189 HREF="node356.html"> Optimization</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html6183 HREF="node358.html"> Constraint Cycles</A>
|
||
|
<HR> <P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|