<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>4.4. Use of Declarations to Improve Efficiency</title><link rel="stylesheet" type="text/css" href="ecl.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="ch27.html" title="Chapter 4. The compiler"><link rel="prev" href="ch27s03.html" title="4.3. Implementation of Compiled Closures"><link rel="next" href="ch27s05.html" title="4.5. Inspecting generated C code"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.4. Use of Declarations to Improve Efficiency</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch27s03.html">Prev</a> </td><th width="60%" align="center">Chapter 4. The compiler</th><td width="20%" align="right"> <a accesskey="n" href="ch27s05.html">Next</a></td></tr></table><hr></div><div class="section" title="4.4. Use of Declarations to Improve Efficiency"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Internals-Use-of-Declarations-to-Improve-Efficiency"></a>4.4. Use of Declarations to Improve Efficiency</h2></div></div></div><p>Declarations, especially type and function declarations, increase the efficiency of the compiled code. For example, for the following Lisp source file, with two Common-Lisp declarations added,</p><pre class="programlisting"> (eval-when (compile) (proclaim '(function tak (fixnum fixnum fixnum) fixnum)) (defun tak (x y z) (declare (fixnum x y z)) (if (not (< y x)) z (tak (tak (1- x) y z) (tak (1- y) z x) (tak (1- z) x y)))) </pre><p>The compiler generates the following C code:</p><pre class="screen"> /* local entry for function TAK */ static int LI1(register int V1,register int V2,register int V3) { VT3 VLEX3 CLSR3 TTL: if (V2 < V1) { goto L2;} return(V3); L2: { int V5; V5 = LI1((V1)-1,V2,V3); { int V6; V6 = LI1((V2)-1,V3,V1); V3 = LI1((V3)-1,V1,V2); V2 = V6; V1 = V5;}} goto TTL; ;;; Note: Tail-recursive call of TAK was replaced by iteration. } </pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch27s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch27.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch27s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.3. Implementation of Compiled Closures </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.5. Inspecting generated C code</td></tr></table></div></body></html>