Commit | Line | Data |
---|---|---|
38a93523 NJ |
1 | @node Obtaining and Installing Guile |
2 | @appendix Obtaining and Installing Guile | |
3 | ||
4 | Here is the information you will need to get and install Guile and extra | |
5 | packages 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 | ||
15 | Guile 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 | |
17 | will 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 | ||
22 | To unbundle Guile use the instruction | |
23 | @example | |
24 | zcat guile-@value{VERSION}.tar.gz | tar xvf - | |
25 | @end example | |
26 | which will create a directory called @file{guile-@value{VERSION}} with | |
27 | all the sources. You can look at the file @file{INSTALL} for detailed | |
28 | instructions on how to build and install Guile, but you should be able | |
29 | to just do | |
30 | @example | |
31 | cd guile-@value{VERSION} | |
32 | ./configure | |
33 | make install | |
34 | @end example | |
35 | ||
36 | This will install the Guile executable @file{guile}, the Guile library | |
37 | @file{libguile.a} and various associated header files and support | |
38 | libraries. It will also install the Guile tutorial and reference manual. | |
39 | ||
40 | @c [[include instructions for getting R4RS]] | |
41 | ||
42 | Since this manual frequently refers to the Scheme ``standard'', also | |
43 | known 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 | |
50 | we have included the report in the Guile distribution; | |
51 | @xref{Top, , Introduction, r4rs, Revised(4) Report on the Algorithmic | |
52 | Language Scheme}. | |
53 | This 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 | ||
59 | We ship the Guile tutorial and reference manual with the Guile | |
60 | distribution [FIXME: this is not currently true (Sat Sep 20 14:13:33 MDT | |
61 | 1997), but will be soon.] Since the Scheme standard (R4RS) is a stable | |
62 | document, we ship that too. | |
63 | ||
64 | Here are references (usually World Wide Web URLs) to some other freely | |
65 | redistributable documents and packages which you might find useful if | |
66 | you are using Guile. | |
67 | ||
68 | @table @strong | |
69 | @item SCSH | |
70 | the Scheme Shell. Gary Houston has ported SCSH to Guile. The relevant | |
71 | chapter (@pxref{The Scheme shell (scsh)}) has references to the SCSH web | |
72 | page with all its documentation. | |
73 | ||
74 | @item SLIB | |
75 | a portable Scheme library maintained by Aubrey Jaffer. SLIB can be | |
76 | obtained by ftp from @url{ftp://prep.ai.mit.edu/pub/gnu/jacal/}. | |
77 | ||
78 | The SLIB package should be unpacked somewhere in Guile's load path. It | |
79 | will typically be unpacked in @file{/usr/local/share/guile/site}, so | |
80 | that it will be @file{/usr/local/share/guile/site/slib}. | |
81 | ||
82 | Guile might have been installed with a different prefix, in which case | |
83 | the load path can be checked from inside the interpreter with: | |
84 | ||
85 | @smalllisp | |
86 | guile> %load-path | |
87 | ("/usr/local/share/guile/site" "/usr/local/share/guile/1.3a" "/usr/local/share/guile" ".") | |
88 | @end smalllisp | |
89 | ||
90 | The relevant chapter (@pxref{SLIB}) has details on how to use SLIB with | |
91 | Guile. | |
92 | ||
93 | @item JACAL | |
94 | a symbolic math package by Aubrey Jaffer. The latest version of Jacal | |
95 | can be obtained from @url{ftp://prep.ai.mit.edu/pub/gnu/jacal/}, and | |
96 | should be unpacked in @file{/usr/local/share/guile/site/slib} so that | |
97 | it will be in @file{/usr/local/share/guile/site/slib/jacal}. | |
98 | ||
99 | The 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 | ||
111 | When debugging a program, programmers often find it helpful to examine | |
112 | the program's internal status while it runs: the values of internal | |
113 | variables, the choices made in @code{if} and @code{cond} statements, and | |
114 | so forth. Guile Scheme provides a debugging interface that programmers | |
115 | can use to single-step through Scheme functions and examine symbol | |
116 | bindings. This is different from the @ref{Debugging}, which permits | |
117 | programmers to debug the Guile interpreter itself. Most programmers | |
118 | will be more interested in debugging their own Scheme programs than the | |
119 | interpreter which evaluates them. | |
120 | ||
121 | [FIXME: should we include examples of traditional debuggers | |
122 | and 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 | ||
137 | When a function is @dfn{traced}, it means that every call to that | |
138 | function is reported to the user during a program run. This can help a | |
139 | programmer determine whether a function is being called at the wrong | |
140 | time or with the wrong set of arguments. | |
141 | ||
142 | @defun trace function | |
143 | Enable debug tracing on @code{function}. While a program is being run, Guile | |
144 | will print a brief report at each call to a traced function, | |
145 | advising the user which function was called and the arguments that were | |
146 | passed to it. | |
147 | @end defun | |
148 | ||
149 | @defun untrace function | |
150 | Disable debug tracing for @code{function}. | |
151 | @end defun | |
152 | ||
153 | Example: | |
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 | ||
180 | Note the way Guile indents the output, illustrating the depth of | |
181 | execution at each function call. This can be used to demonstrate, for | |
182 | example, 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 | ||
204 | Since the tail call is effectively optimized to a @code{goto} statement, | |
205 | there is no need for Guile to create a new stack frame for each | |
206 | iteration. 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 | ||
214 | When a running program is interrupted, usually upon reaching an error or | |
215 | breakpoint, its state is represented by a @dfn{stack} of suspended | |
216 | function calls, each of which is called a @dfn{frame}. The programmer | |
217 | can learn more about the program's state at the point of interruption by | |
218 | inspecting and modifying these frames. | |
219 | ||
220 | @deffn primitive stack? obj | |
221 | Return @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 | |
228 | Evaluate @var{exp} on a new calling stack with identity @var{id}. If | |
229 | @var{exp} is interrupted during evaluation, backtraces will not display | |
230 | frames farther back than @var{exp}'s top-level form. This macro is a | |
231 | way of artificially limiting backtraces and stack procedures, largely as | |
232 | a convenience to the user. | |
233 | @end deffn | |
234 | ||
235 | @deffn primitive stack-id stack | |
236 | Return 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 |