1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/d_optimi.htm
2024-04-01 10:24:07 +02:00

77 lines
6.3 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Declaration OPTIMIZE</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="d_declar.htm">
<LINK REL=UP HREF="c_evalua.htm">
<LINK REL=NEXT HREF="d_specia.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="d_declar.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_evalua.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="d_specia.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="optimize"><I>Declaration</I> <B>OPTIMIZE</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<TT>(optimize </TT>{<TT></TT><I>quality</I><TT> </TT>|<TT> (</TT><I>quality</I><TT> </TT><I>value</I><TT>)</TT>}<TT></TT>*<TT>)</TT> <A NAME="compilation-speed"></A><A NAME="debug"></A><A NAME="safety"></A><A NAME="space"></A><A NAME="speed"></A> <P>
<P><B>Arguments:</B><P>
<P>
<I>quality</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#optimize_quality"><I>optimize quality</I></A>. <P>
<I>value</I>---one of the <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integers</I></A> <TT>0</TT>, <TT>1</TT>, <TT>2</TT>, or <TT>3</TT>. <P>
<P><B>Valid Context:</B><P>
<P>
<A REL=DEFINITION HREF="26_glo_d.htm#declaration"><I>declaration</I></A> or <A REL=DEFINITION HREF="26_glo_p.htm#proclamation"><I>proclamation</I></A> <P>
<P><B>Binding Types Affected:</B> None.
<P>
<P><B>Description:</B><P>
<P>
Advises the compiler that each <I>quality</I> should be given attention according to the specified corresponding <I>value</I>. Each <I>quality</I> must be a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> naming an <A REL=DEFINITION HREF="26_glo_o.htm#optimize_quality"><I>optimize quality</I></A>; the names and meanings of the standard <I>optimize qualities</I> are shown in the next figure. <P>
<PRE>
Name Meaning
<A REL=DEFINITION HREF="#compilation-speed">compilation-speed</A> speed of the compilation process
<A REL=DEFINITION HREF="#debug">debug</A> ease of debugging
<A REL=DEFINITION HREF="#safety">safety</A> run-time error checking
<A REL=DEFINITION HREF="#space">space</A> both code size and run-time space
<A REL=DEFINITION HREF="#speed">speed</A> speed of the object code
</PRE>
<P><B>Figure 3-25. Optimize qualities</B> <P>
There may be other, <A REL=DEFINITION HREF="26_glo_i.htm#implementation-defined"><I>implementation-defined</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#optimize_quality"><I>optimize qualities</I></A>. <P>
A <I>value</I> <TT>0</TT> means that the corresponding <I>quality</I> is totally unimportant, and <TT>3</TT> that the <I>quality</I> is extremely important; <TT>1</TT> and <TT>2</TT> are intermediate values, with <TT>1</TT> the neutral value. <TT>(</TT><I>quality</I><TT> 3)</TT> can be abbreviated to <I>quality</I>. <P>
Note that <A REL=DEFINITION HREF="26_glo_c.htm#code"><I>code</I></A> which has the optimization <TT>(safety 3)</TT>, or just <B>safety</B>, is called <A REL=DEFINITION HREF="26_glo_s.htm#safe"><I>safe</I></A> <A REL=DEFINITION HREF="26_glo_c.htm#code"><I>code</I></A>. <P>
The consequences are unspecified if a <I>quality</I> appears more than once with <A REL=DEFINITION HREF="26_glo_d.htm#different"><I>different</I></A> <I>values</I>. <P>
<P><B>Examples:</B><P>
<P>
<PRE>
(defun often-used-subroutine (x y)
(declare (optimize (safety 2)))
(error-check x y)
(hairy-setup x)
(do ((i 0 (+ i 1))
(z x (cdr z)))
((null z))
;; This inner loop really needs to burn.
(declare (optimize speed))
(declare (fixnum i))
))
</PRE>
</TT> <P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="s_declar.htm#declare"><B>declare</B></A>, <A REL=DEFINITION HREF="m_declai.htm#declaim"><B>declaim</B></A>, <A REL=DEFINITION HREF="f_procla.htm#proclaim"><B>proclaim</B></A>, <A REL=CHILD HREF="03_cd.htm">Section 3.3.4 (Declaration Scope)</A> <P>
<P><B>Notes:</B><P>
<P>
An <A REL=DEFINITION HREF="#optimize"><B>optimize</B></A> declaration never applies to either a <A REL=DEFINITION HREF="26_glo_v.htm#variable"><I>variable</I></A> or a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="26_glo_b.htm#binding"><I>binding</I></A>. An <A REL=DEFINITION HREF="#optimize"><B>optimize</B></A> declaration can only be a <A REL=DEFINITION HREF="26_glo_f.htm#free_declaration"><I>free declaration</I></A>. For more information, see <A REL=CHILD HREF="03_cd.htm">Section 3.3.4 (Declaration Scope)</A>. <P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss251.htm">OPTIMIZE-DEBUG-INFO:NEW-QUALITY</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>