* Minor docstring updates.
[bpt/guile.git] / doc / appendices.texi
CommitLineData
38a93523
NJ
1@node Obtaining and Installing Guile
2@appendix Obtaining and Installing Guile
3
4Here is the information you will need to get and install Guile and extra
5packages and documentation you might need or find interesting.
6
7@menu
8* The Basic Guile Package::
9* Packages not shipped with Guile::
10@end menu
11
12@node The Basic Guile Package
13@section The Basic Guile Package
14
15Guile can be obtained from the main GNU archive site
16@url{ftp://prep.ai.mit.edu/pub/gnu} or any of its mirrors. The file
17will be named guile-version.tar.gz. The current version is
18@value{VERSION}, so the file you should grab is:
19
20@url{ftp://prep.ai.mit.edu/pub/gnu/guile-@value{VERSION}.tar.gz}
21
22To unbundle Guile use the instruction
23@example
24zcat guile-@value{VERSION}.tar.gz | tar xvf -
25@end example
26which will create a directory called @file{guile-@value{VERSION}} with
27all the sources. You can look at the file @file{INSTALL} for detailed
28instructions on how to build and install Guile, but you should be able
29to just do
30@example
31cd guile-@value{VERSION}
32./configure
33make install
34@end example
35
36This will install the Guile executable @file{guile}, the Guile library
37@file{libguile.a} and various associated header files and support
38libraries. It will also install the Guile tutorial and reference manual.
39
40@c [[include instructions for getting R4RS]]
41
42Since this manual frequently refers to the Scheme ``standard'', also
43known as R4RS, or the
44@iftex
45``Revised$^4$ Report on the Algorithmic Language Scheme'',
46@end iftex
47@ifinfo
48``Revised^4 Report on the Algorithmic Language Scheme'',
49@end ifinfo
50we have included the report in the Guile distribution;
51@xref{Top, , Introduction, r4rs, Revised(4) Report on the Algorithmic
52Language Scheme}.
53This will also be installed in your info directory.
54
55
56@node Packages not shipped with Guile
57@section Packages not shipped with Guile
58
59We ship the Guile tutorial and reference manual with the Guile
60distribution [FIXME: this is not currently true (Sat Sep 20 14:13:33 MDT
611997), but will be soon.] Since the Scheme standard (R4RS) is a stable
62document, we ship that too.
63
64Here are references (usually World Wide Web URLs) to some other freely
65redistributable documents and packages which you might find useful if
66you are using Guile.
67
68@table @strong
69@item SCSH
70the Scheme Shell. Gary Houston has ported SCSH to Guile. The relevant
71chapter (@pxref{The Scheme shell (scsh)}) has references to the SCSH web
72page with all its documentation.
73
74@item SLIB
75a portable Scheme library maintained by Aubrey Jaffer. SLIB can be
76obtained by ftp from @url{ftp://prep.ai.mit.edu/pub/gnu/jacal/}.
77
78The SLIB package should be unpacked somewhere in Guile's load path. It
79will typically be unpacked in @file{/usr/local/share/guile/site}, so
80that it will be @file{/usr/local/share/guile/site/slib}.
81
82Guile might have been installed with a different prefix, in which case
83the load path can be checked from inside the interpreter with:
84
85@smalllisp
86guile> %load-path
87("/usr/local/share/guile/site" "/usr/local/share/guile/1.3a" "/usr/local/share/guile" ".")
88@end smalllisp
89
90The relevant chapter (@pxref{SLIB}) has details on how to use SLIB with
91Guile.
92
93@item JACAL
94a symbolic math package by Aubrey Jaffer. The latest version of Jacal
95can be obtained from @url{ftp://prep.ai.mit.edu/pub/gnu/jacal/}, and
96should be unpacked in @file{/usr/local/share/guile/site/slib} so that
97it will be in @file{/usr/local/share/guile/site/slib/jacal}.
98
99The relevant section (@pxref{JACAL}) has details on how to use Jacal.
100@end table
101
102
103@page
104@node Debugger User Interface
105@appendix Debugger User Interface
106
107@c --- The title and introduction of this appendix need to
108@c distinguish this clearly from the chapter on the internal
109@c debugging interface.
110
111When debugging a program, programmers often find it helpful to examine
112the program's internal status while it runs: the values of internal
113variables, the choices made in @code{if} and @code{cond} statements, and
114so forth. Guile Scheme provides a debugging interface that programmers
115can use to single-step through Scheme functions and examine symbol
116bindings. This is different from the @ref{Debugging}, which permits
117programmers to debug the Guile interpreter itself. Most programmers
118will be more interested in debugging their own Scheme programs than the
119interpreter which evaluates them.
120
121[FIXME: should we include examples of traditional debuggers
122and explain why they can't be used to debug interpreted Scheme or Lisp?]
123
124@menu
125* Single-Step:: Execute a program or function one step at a time.
126* Trace:: Print a report each time a given function is called.
127* Backtrace:: See a list of the statements that caused an error.
128* Stacks and Frames:: Examine the state of an interrupted program.
129@end menu
130
131@node Single-Step
132@appendixsec Single-Step
133
134@node Trace
135@appendixsec Trace
136
137When a function is @dfn{traced}, it means that every call to that
138function is reported to the user during a program run. This can help a
139programmer determine whether a function is being called at the wrong
140time or with the wrong set of arguments.
141
142@defun trace function
143Enable debug tracing on @code{function}. While a program is being run, Guile
144will print a brief report at each call to a traced function,
145advising the user which function was called and the arguments that were
146passed to it.
147@end defun
148
149@defun untrace function
150Disable debug tracing for @code{function}.
151@end defun
152
153Example:
154
155@lisp
156(define (rev ls)
157 (if (null? ls)
158 '()
159 (append (rev (cdr ls))
160 (cons (car ls) '())))) @result{} rev
161
162(trace rev) @result{} (rev)
163
164(rev '(a b c d e))
165@result{} [rev (a b c d e)]
166 | [rev (b c d e)]
167 | | [rev (c d e)]
168 | | | [rev (d e)]
169 | | | | [rev (e)]
170 | | | | | [rev ()]
171 | | | | | ()
172 | | | | (e)
173 | | | (e d)
174 | | (e d c)
175 | (e d c b)
176 (e d c b a)
177 (e d c b a)
178@end lisp
179
180Note the way Guile indents the output, illustrating the depth of
181execution at each function call. This can be used to demonstrate, for
182example, that Guile implements self-tail-recursion properly:
183
184@lisp
185(define (rev ls sl)
186 (if (null? ls)
187 sl
188 (rev (cdr ls)
189 (cons (car ls) sl)))) @result{} rev
190
191(trace rev) @result{} (rev)
192
193(rev '(a b c d e) '())
194@result{} [rev (a b c d e) ()]
195 [rev (b c d e) (a)]
196 [rev (c d e) (b a)]
197 [rev (d e) (c b a)]
198 [rev (e) (d c b a)]
199 [rev () (e d c b a)]
200 (e d c b a)
201 (e d c b a)
202@end lisp
203
204Since the tail call is effectively optimized to a @code{goto} statement,
205there is no need for Guile to create a new stack frame for each
206iteration. Using @code{trace} here helps us see why this is so.
207
208@node Backtrace
209@appendixsec Backtrace
210
211@node Stacks and Frames
212@appendixsec Stacks and Frames
213
214When a running program is interrupted, usually upon reaching an error or
215breakpoint, its state is represented by a @dfn{stack} of suspended
216function calls, each of which is called a @dfn{frame}. The programmer
217can learn more about the program's state at the point of interruption by
218inspecting and modifying these frames.
219
220@deffn primitive stack? obj
221Return @code{#t} if @var{obj} is a calling stack.
222@end deffn
223
224@deffn primitive make-stack
225@end deffn
226
227@deffn syntax start-stack id exp
228Evaluate @var{exp} on a new calling stack with identity @var{id}. If
229@var{exp} is interrupted during evaluation, backtraces will not display
230frames farther back than @var{exp}'s top-level form. This macro is a
231way of artificially limiting backtraces and stack procedures, largely as
232a convenience to the user.
233@end deffn
234
235@deffn primitive stack-id stack
236Return the identifier given to @var{stack} by @code{start-stack}.
237@end deffn
238
239@deffn primitive stack-ref
240@end deffn
241
242@deffn primitive stack-length
243@end deffn
244
245@deffn primitive frame?
246@end deffn
247
248@deffn primitive last-stack-frame
249@end deffn
250
251@deffn primitive frame-number
252@end deffn
253
254@deffn primitive frame-source
255@end deffn
256
257@deffn primitive frame-procedure
258@end deffn
259
260@deffn primitive frame-arguments
261@end deffn
262
263@deffn primitive frame-previous
264@end deffn
265
266@deffn primitive frame-next
267@end deffn
268
269@deffn primitive frame-real?
270@end deffn
271
272@deffn primitive frame-procedure?
273@end deffn
274
275@deffn primitive frame-evaluating-args?
276@end deffn
277
278@deffn primitive frame-overflow
279@end deffn