0.pre7.133:
[sbcl.git] / doc / beyond-ansi.sgml
1 <chapter id="beyond-ansi"><title>Beyond the &ANSI; Standard</>
2
3 <para>Besides &ANSI;, we have other stuff..</para>
4
5 <sect1 id="non-conformance"><title>Non-Conformance with the &ANSI; Standard</>
6
7 <para>
8 This section is essentially a placeholder. There is are
9 important areas of non-conformance, like the difference
10 between <function>sb-pcl:find-class</> and <function>cl:class</>,
11 but progress is made
12 and the list changes and I've tired of trying to keep
13 the information here up to date. For information on the
14 highlights, try the bugs sections of the Unix man page.
15 For more detailed information, try the BUGS file in the 
16 system distribution.
17 </para>
18
19 </sect1>
20
21 <sect1 id="idiosyncrasies"><title>Idiosyncrasies</>
22
23 <para>Declarations are generally treated as assertions. This general
24 principle, and its implications, and the bugs which still keep the
25 compiler from quite satisfying this principle, are discussed in the
26 <link linkend="compiler">chapter on the compiler</link>.</para>
27
28 <para>&SBCL; is essentially a compiler-only implementation of
29 &CommonLisp;. That is, for all but a few special cases,
30 <function>eval</> creates a
31 lambda expression, calls <function>compile</> on the lambda
32 expression to create a compiled function, and then calls
33 <function>funcall</> on the resulting function object. This 
34 is explicitly allowed by the &ANSI; standard, but leads to some
35 oddities, e.g. collapsing <function>functionp</> and 
36 <function>compiled-function-p</> into the same predicate.
37 </para>
38
39 </sect1>
40
41 <sect1 id="extensions"><title>Extensions</>
42
43 <para>&SBCL; is derived from &CMUCL;, which implements many extensions
44 to the &ANSI; standard. &SBCL; doesn't support as many extensions as
45 &CMUCL;, but it still has quite a few.</para>
46
47 <sect2><title>Things Which Might Be in the Next &ANSI; Standard</>
48
49 <para>&SBCL; provides extensive support for 
50 calling external C code, described 
51 <link linkend="ffi">in its own chapter</link>.</para>
52
53 <para>&SBCL; provides additional garbage collection functionality not
54 specified by &ANSI;. Weak pointers allow references to objects to be
55 maintained without keeping them from being GCed. And "finalization"
56 hooks are available to cause code to be executed when an object is
57 GCed.</para> <!-- FIXME: Actually documenting these would be good.:-| -->
58
59 <para>&SBCL; supports Gray streams, user-overloadable CLOS classes
60 whose instances can be used as Lisp streams (e.g. passed as the
61 first argument to <function>format</>).</para>
62
63 </sect2>
64
65 <sect2><title>Support for Unix</>
66
67 <para>The UNIX command line can be read from the variable
68 <varname>sb-ext:*posix-argv*</>. The UNIX environment can be queried with the
69 <function>sb-ext:posix-getenv</> function.</para>
70
71 <para>The &SBCL; system can be terminated with <function>sb-ext:quit</>,
72 optionally returning a specified numeric value to the calling Unix
73 process. The normal Unix idiom of terminating on end of file on input
74 is also supported.</para>
75
76 </sect2>
77
78 <sect2><title>Tools to Help Developers</title>
79
80 <para>&SBCL; provides a profiler and other extensions to the &ANSI;
81 <function>trace</> facility. See the online function documentation for
82 <function>trace</> for more information.</para>
83
84 <para>The debugger supports a number of options. Its documentation is
85 accessed by typing <userinput>help</> at the debugger prompt.</para>
86 <!-- FIXME:
87      A true debugger section in the manual would be good. Start
88      with CMU CL's debugger section, but remember:
89        * no QUIT command (TOPLEVEL restart instead)
90        * no GO command (CONTINUE restart instead)
91        * Limitations of the x86 port of the debugger should be 
92          documented or fixed where possible.
93        * Discuss TRACE and its unification with PROFILE. -->
94
95 <para>Documentation for <function>inspect</> is accessed by typing
96 <userinput>help</> at the <function>inspect</> prompt.</para>
97
98 </sect2>
99
100 <sect2><title>Interface to Low-Level &SBCL; Implementation</title>
101
102 <para>&SBCL; has the ability to save its state as a file for later
103 execution. This functionality is important for its bootstrapping
104 process, and is also provided as an extension to the user See the
105 documentation for <function>sb-ext:save-lisp-and-die</> for more
106 information.</para>
107
108 <note><para>&SBCL; has inherited from &CMUCL; various hooks to allow
109 the user to tweak and monitor the garbage collection process. These
110 are somewhat stale code, and their interface might need to be cleaned
111 up. If you have urgent need of them, look at the code in
112 <filename>src/code/gc.lisp</filename> and bring it up on the
113 developers' mailing list.</para></note>
114
115 <note><para>&SBCL; has various hooks inherited from &CMUCL;, like
116 <function>sb-ext:float-denormalized-p</>, to allow a program to take
117 advantage of &IEEE; floating point arithmetic properties which aren't
118 conveniently or efficiently expressible using the &ANSI; standard. These
119 look good, and their interface looks good, but &IEEE; support is
120 slightly broken due to a stupid decision to remove some support for
121 infinities (because it wasn't in the &ANSI; spec and it didn't occur to
122 me that it was in the &IEEE; spec). If you need this stuff, take a look
123 at the ecode and bring it up on the developers' mailing
124 list.</para></note>
125
126 </sect2>
127
128 <sect2><title>Efficiency Hacks</title>
129
130 <para>The <function>sb-ext:purify</function> function causes &SBCL;
131 first to collect all garbage, then to mark all uncollected objects as
132 permanent, never again attempting to collect them as garbage. (This
133 can cause a large increase in efficiency when using a primitive
134 garbage collector, but is less important with modern generational
135 garbage collectors.)</para>
136
137 <para>The <function>sb-ext:truly-the</> operator does what the
138 <function>cl:the</> operator does in a more conventional
139 implementation of &CommonLisp;, declaring the type of its argument
140 without any runtime checks. (Ordinarily in &SBCL;, any type declaration
141 is treated as an assertion and checked at runtime.)</para>
142
143 <para>The <function>sb-ext:freeze-type</> declaration declares that a
144 type will never change, which can make type testing
145 (<function>typep</>, etc.) more efficient for structure types.</para>
146
147 <para>The <function>sb-ext:constant-function</> declaration specifies
148 that a function will always return the same value for the same
149 arguments. This is appropriate for functions like <function>sqrt</>.
150 It is not appropriate for functions like <function>aref</>, which can
151 change their return values when the underlying data are
152 changed.</para>
153
154 </sect2>
155
156 </sect1>
157
158 </chapter>