debug and readline options doc tweak
[bpt/guile.git] / doc / ref / api-options.texi
CommitLineData
07d83abe
MV
1@c -*-texinfo-*-
2@c This is part of the GNU Guile Reference Manual.
6ea30487 3@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010
07d83abe
MV
4@c Free Software Foundation, Inc.
5@c See the file guile.texi for copying conditions.
6
07d83abe
MV
7@node Options and Config
8@section Configuration, Features and Runtime Options
9
10Why is my Guile different from your Guile? There are three kinds of
11possible variation:
12
13@itemize @bullet
14@item
15build differences --- different versions of the Guile source code,
16installation directories, configuration flags that control pieces of
17functionality being included or left out, etc.
18
19@item
20differences in dynamically loaded code --- behaviour and features
21provided by modules that can be dynamically loaded into a running Guile
22
23@item
24different runtime options --- some of the options that are provided for
25controlling Guile's behaviour may be set differently.
26@end itemize
27
28Guile provides ``introspective'' variables and procedures to query all
29of these possible variations at runtime. For runtime options, it also
30provides procedures to change the settings of options and to obtain
31documentation on what the options mean.
32
33@menu
34* Build Config:: Build and installation configuration.
35* Feature Tracking:: Available features in the Guile process.
36* Runtime Options:: Controlling Guile's runtime behaviour.
37@end menu
38
39
40@node Build Config
41@subsection Configuration, Build and Installation
42
43The following procedures and variables provide information about how
44Guile was configured, built and installed on your system.
45
46@deffn {Scheme Procedure} version
47@deffnx {Scheme Procedure} effective-version
48@deffnx {Scheme Procedure} major-version
49@deffnx {Scheme Procedure} minor-version
50@deffnx {Scheme Procedure} micro-version
51@deffnx {C Function} scm_version ()
52@deffnx {C Function} scm_effective_version ()
53@deffnx {C Function} scm_major_version ()
54@deffnx {C Function} scm_minor_version ()
55@deffnx {C Function} scm_micro_version ()
56Return a string describing Guile's full version number, effective
57version number, major, minor or micro version number, respectively.
58The @code{effective-version} function returns the version name that
59should remain unchanged during a stable series. Currently that means
60that it omits the micro version. The effective version should be used
61for items like the versioned share directory name
62i.e. @file{/usr/share/guile/1.6/}
63
64@lisp
65(version) @result{} "1.6.0"
66(effective-version) @result{} "1.6"
67(major-version) @result{} "1"
68(minor-version) @result{} "6"
69(micro-version) @result{} "0"
70@end lisp
71@end deffn
72
73@deffn {Scheme Procedure} %package-data-dir
74@deffnx {C Function} scm_sys_package_data_dir ()
75Return the name of the directory under which Guile Scheme files in
76general are stored. On Unix-like systems, this is usually
77@file{/usr/local/share/guile} or @file{/usr/share/guile}.
78@end deffn
79
80@deffn {Scheme Procedure} %library-dir
81@deffnx {C Function} scm_sys_library_dir ()
82Return the name of the directory where the Guile Scheme files that
83belong to the core Guile installation (as opposed to files from a 3rd
45867c2a 84party package) are installed. On Unix-like systems this is usually
07d83abe 85@file{/usr/local/share/guile/<GUILE_EFFECTIVE_VERSION>} or
45867c2a
NJ
86@file{/usr/share/guile/<GUILE_EFFECTIVE_VERSION>};
87
88@noindent for example @file{/usr/local/share/guile/1.6}.
07d83abe
MV
89@end deffn
90
91@deffn {Scheme Procedure} %site-dir
92@deffnx {C Function} scm_sys_site_dir ()
93Return the name of the directory where Guile Scheme files specific to
94your site should be installed. On Unix-like systems, this is usually
95@file{/usr/local/share/guile/site} or @file{/usr/share/guile/site}.
96@end deffn
97
98@cindex GUILE_LOAD_PATH
99@defvar %load-path
100List of directories which should be searched for Scheme modules and
101libraries. @code{%load-path} is initialized when Guile starts up to
8370b00b 102@code{(list (%site-dir) (%library-dir) (%package-data-dir))},
07d83abe
MV
103prepended with the contents of the GUILE_LOAD_PATH environment variable,
104if it is set.
105@end defvar
106
107@deffn {Scheme Procedure} parse-path path [tail]
108@deffnx {C Function} scm_parse_path (path, tail)
109Parse @var{path}, which is expected to be a colon-separated
110string, into a list and return the resulting list with
111@var{tail} appended. If @var{path} is @code{#f}, @var{tail}
112is returned.
113@end deffn
114
88cbb421
LC
115@deffn {Scheme Procedure} search-path path filename [extensions [require-exts?]]
116@deffnx {C Function} scm_search_path (path, filename, rest)
07d83abe
MV
117Search @var{path} for a directory containing a file named
118@var{filename}. The file must be readable, and not a directory.
119If we find one, return its full filename; otherwise, return
120@code{#f}. If @var{filename} is absolute, return it unchanged.
121If given, @var{extensions} is a list of strings; for each
122directory in @var{path}, we search for @var{filename}
88cbb421
LC
123concatenated with each @var{extension}. If @var{require-exts?}
124is true, require that the returned file name have one of the
125given extensions; if @var{require-exts?} is not given, it
126defaults to @code{#f}.
127
128For compatibility with Guile 1.8 and earlier, the C function takes only
129three arguments
07d83abe
MV
130@end deffn
131
132@defvar %guile-build-info
133Alist of information collected during the building of a particular
134Guile. Entries can be grouped into one of several categories:
135directories, env vars, and versioning info.
136
137Briefly, here are the keys in @code{%guile-build-info}, by group:
138
139@cindex @code{srcdir}
140@cindex @code{top_srcdir}
141@cindex @code{prefix}
142@cindex @code{exec_prefix}
143@cindex @code{bindir}
144@cindex @code{sbindir}
145@cindex @code{libexecdir}
146@cindex @code{datadir}
147@cindex @code{sysconfdir}
148@cindex @code{sharedstatedir}
149@cindex @code{localstatedir}
150@cindex @code{libdir}
151@cindex @code{infodir}
152@cindex @code{mandir}
153@cindex @code{includedir}
154@cindex @code{pkgdatadir}
155@cindex @code{pkglibdir}
156@cindex @code{pkgincludedir}
157@table @asis
158@item directories
159srcdir, top_srcdir, prefix, exec_prefix, bindir, sbindir, libexecdir,
160datadir, sysconfdir, sharedstatedir, localstatedir, libdir, infodir,
161mandir, includedir, pkgdatadir, pkglibdir, pkgincludedir
162@cindex @code{LIBS}
163@item env vars
164LIBS
165@cindex @code{guileversion}
166@cindex @code{libguileinterface}
167@cindex @code{buildstamp}
168@item versioning info
169guileversion, libguileinterface, buildstamp
170@end table
171
172Values are all strings. The value for @code{LIBS} is typically found
173also as a part of "guile-config link" output. The value for
174@code{guileversion} has form X.Y.Z, and should be the same as returned
73e46534
KR
175by @code{(version)}. The value for @code{libguileinterface} is
176libtool compatible and has form CURRENT:REVISION:AGE
177(@pxref{Versioning,, Library interface versions, libtool, GNU
178Libtool}). The value for @code{buildstamp} is the output of the
a6025413 179command @samp{date -u +'%Y-%m-%d %T'} (UTC).
07d83abe
MV
180
181In the source, @code{%guile-build-info} is initialized from
182libguile/libpath.h, which is completely generated, so deleting this file
183before a build guarantees up-to-date values for that build.
184@end defvar
185
d7a22073
LC
186@cindex GNU triplet
187@cindex canonical host type
188
189@defvar %host-type
190The canonical host type (GNU triplet) of the host Guile was configured
191for, e.g., @code{"x86_64-unknown-linux-gnu"} (@pxref{Canonicalizing,,,
192autoconf, The GNU Autoconf Manual}).
193@end defvar
07d83abe
MV
194
195@node Feature Tracking
196@subsection Feature Tracking
197
198Guile has a Scheme level variable @code{*features*} that keeps track to
199some extent of the features that are available in a running Guile.
200@code{*features*} is a list of symbols, for example @code{threads}, each
201of which describes a feature of the running Guile process.
202
203@defvar *features*
204A list of symbols describing available features of the Guile process.
205@end defvar
206
207You shouldn't modify the @code{*features*} variable directly using
208@code{set!}. Instead, see the procedures that are provided for this
209purpose in the following subsection.
210
211@menu
212* Feature Manipulation:: Checking for and advertising features.
213* Common Feature Symbols:: Commonly available features.
214@end menu
215
216
217@node Feature Manipulation
218@subsubsection Feature Manipulation
219
220To check whether a particular feature is available, use the
221@code{provided?} procedure:
222
223@deffn {Scheme Procedure} provided? feature
224@deffnx {Deprecated Scheme Procedure} feature? feature
225Return @code{#t} if the specified @var{feature} is available, otherwise
226@code{#f}.
227@end deffn
228
229To advertise a feature from your own Scheme code, you can use the
230@code{provide} procedure:
231
232@deffn {Scheme Procedure} provide feature
233Add @var{feature} to the list of available features in this Guile
234process.
235@end deffn
236
237For C code, the equivalent function takes its feature name as a
238@code{char *} argument for convenience:
239
240@deftypefn {C Function} void scm_add_feature (const char *str)
241Add a symbol with name @var{str} to the list of available features in
242this Guile process.
243@end deftypefn
244
245
246@node Common Feature Symbols
247@subsubsection Common Feature Symbols
248
249In general, a particular feature may be available for one of two
250reasons. Either because the Guile library was configured and compiled
251with that feature enabled --- i.e. the feature is built into the library
252on your system. Or because some C or Scheme code that was dynamically
253loaded by Guile has added that feature to the list.
254
255In the first category, here are the features that the current version of
256Guile may define (depending on how it is built), and what they mean.
257
258@table @code
259@item array
260Indicates support for arrays (@pxref{Arrays}).
261
262@item array-for-each
263Indicates availability of @code{array-for-each} and other array mapping
40499598 264procedures (@pxref{Arrays}).
07d83abe
MV
265
266@item char-ready?
267Indicates that the @code{char-ready?} function is available
268(@pxref{Reading}).
269
270@item complex
271Indicates support for complex numbers.
272
273@item current-time
274Indicates availability of time-related functions: @code{times},
275@code{get-internal-run-time} and so on (@pxref{Time}).
276
277@item debug-extensions
278Indicates that the debugging evaluator is available, together with the
279options for controlling it.
280
281@item delay
282Indicates support for promises (@pxref{Delayed Evaluation}).
283
284@item EIDs
285Indicates that the @code{geteuid} and @code{getegid} really return
286effective user and group IDs (@pxref{Processes}).
287
288@item inexact
289Indicates support for inexact numbers.
290
291@item i/o-extensions
292Indicates availability of the following extended I/O procedures:
293@code{ftell}, @code{redirect-port}, @code{dup->fdes}, @code{dup2},
294@code{fileno}, @code{isatty?}, @code{fdopen},
295@code{primitive-move->fdes} and @code{fdes->ports} (@pxref{Ports and
296File Descriptors}).
297
298@item net-db
299Indicates availability of network database functions:
300@code{scm_gethost}, @code{scm_getnet}, @code{scm_getproto},
301@code{scm_getserv}, @code{scm_sethost}, @code{scm_setnet}, @code{scm_setproto},
302@code{scm_setserv}, and their `byXXX' variants (@pxref{Network
303Databases}).
304
305@item posix
306Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
307@code{kill}, @code{execl} and so on (@pxref{POSIX}).
308
309@item random
310Indicates availability of random number generation functions:
311@code{random}, @code{copy-random-state}, @code{random-uniform} and so on
312(@pxref{Random}).
313
314@item reckless
315Indicates that Guile was built with important checks omitted --- you
316should never see this!
317
318@item regex
319Indicates support for POSIX regular expressions using
320@code{make-regexp}, @code{regexp-exec} and friends (@pxref{Regexp
321Functions}).
322
323@item socket
324Indicates availability of socket-related functions: @code{socket},
325@code{bind}, @code{connect} and so on (@pxref{Network Sockets and
326Communication}).
327
328@item sort
329Indicates availability of sorting and merging functions
330(@pxref{Sorting}).
331
332@item system
333Indicates that the @code{system} function is available
334(@pxref{Processes}).
335
336@item threads
337Indicates support for multithreading (@pxref{Threads}).
338
339@item values
340Indicates support for multiple return values using @code{values} and
341@code{call-with-values} (@pxref{Multiple Values}).
342@end table
343
344Available features in the second category depend, by definition, on what
345additional code your Guile process has loaded in. The following table
346lists features that you might encounter for this reason.
347
348@table @code
349@item defmacro
350Indicates that the @code{defmacro} macro is available (@pxref{Macros}).
351
352@item describe
353Indicates that the @code{(oop goops describe)} module has been loaded,
354which provides a procedure for describing the contents of GOOPS
355instances.
356
357@item readline
358Indicates that Guile has loaded in Readline support, for command line
359editing (@pxref{Readline Support}).
360
361@item record
362Indicates support for record definition using @code{make-record-type}
363and friends (@pxref{Records}).
364@end table
365
366Although these tables may seem exhaustive, it is probably unwise in
367practice to rely on them, as the correspondences between feature symbols
368and available procedures/behaviour are not strictly defined. If you are
369writing code that needs to check for the existence of some procedure, it
370is probably safer to do so directly using the @code{defined?} procedure
371than to test for the corresponding feature using @code{provided?}.
372
373
374@node Runtime Options
375@subsection Runtime Options
376
377Guile's runtime behaviour can be modified by setting options. For
378example, is the language that Guile accepts case sensitive, or should
379the debugger automatically show a backtrace on error?
380
381Guile has two levels of interface for managing options: a low-level
382control interface, and a user-level interface which allows the enabling
383or disabling of options.
384
385Moreover, the options are classified in groups according to whether they
1518f649 386configure @emph{reading}, @emph{printing}, or @emph{debugging}.
07d83abe
MV
387
388@menu
07d83abe 389* Debugger options::
07d83abe
MV
390* Examples of option use::
391@end menu
392
393
07d83abe
MV
394@node Debugger options
395@subsubsection Debugger options
396
397Here is the list of print options generated by typing
84898084 398@code{(debug-options 'help)} in Guile. You can also see the default
07d83abe
MV
399values.
400
401@smallexample
84898084
AW
402backwards no Display backtrace in anti-chronological order.
403width 79 Maximal width of backtrace.
404depth 20 Maximal length of printed backtrace.
405backtrace yes Show backtrace on error.
406stack 1048576 Stack size limit (measured in words;
407 0 = no check).
408show-file-name #t Show file names and line numbers in backtraces
3932bdb3 409 when not `#f'. A value of `base' displays only
84898084
AW
410 base names, while `#t' displays full names.
411warn-deprecated no Warn when deprecated features are used.
07d83abe
MV
412@end smallexample
413
414@subsubheading Stack overflow
415
416@cindex overflow, stack
417@cindex stack overflow
418Stack overflow errors are caused by a computation trying to use more
419stack space than has been enabled by the @code{stack} option. They are
420reported like this:
421
422@lisp
423(non-tail-recursive-factorial 500)
424@print{}
425ERROR: Stack overflow
426ABORT: (stack-overflow)
427@end lisp
428
429If you get an error like this, you can either try rewriting your code to
430use less stack space, or increase the maximum stack size. To increase
431the maximum stack size, use @code{debug-set!}, for example:
432
433@lisp
434(debug-set! stack 200000)
435@result{}
45867c2a
NJ
436(show-file-name #t stack 200000 debug backtrace depth 20
437 maxdepth 1000 frames 3 indent 10 width 79 procnames cheap)
07d83abe
MV
438
439(non-tail-recursive-factorial 500)
440@result{}
441122013682599111006870123878542304692625357434@dots{}
442@end lisp
443
444If you prefer to try rewriting your code, you may be able to save stack
bfc083ec
KR
445space by making some of your procedures @dfn{tail recursive}
446(@pxref{Tail Calls}).
07d83abe
MV
447
448
449@node Examples of option use
450@subsubsection Examples of option use
451
452Here is an example of a session in which some read and debug option
453handling procedures are used. In this example, the user
454
455@enumerate
456@item
457Notices that the symbols @code{abc} and @code{aBc} are not the same
458@item
459Examines the @code{read-options}, and sees that @code{case-insensitive}
460is set to ``no''.
461@item
462Enables @code{case-insensitive}
463@item
464Verifies that now @code{aBc} and @code{abc} are the same
465@item
466Disables @code{case-insensitive} and enables debugging @code{backtrace}
467@item
468Reproduces the error of displaying @code{aBc} with backtracing enabled
469[FIXME: this last example is lame because there is no depth in the
470backtrace. Need to give a better example, possibly putting debugging
471option examples in a separate session.]
472@end enumerate
473
07d83abe
MV
474@smalllisp
475guile> (define abc "hello")
476guile> abc
477"hello"
478guile> aBc
479ERROR: In expression aBc:
480ERROR: Unbound variable: aBc
481ABORT: (misc-error)
482
483Type "(backtrace)" to get more information.
484guile> (read-options 'help)
ef4cbc08 485keywords #f Style of keyword recognition: #f, 'prefix or 'postfix
07d83abe
MV
486case-insensitive no Convert symbols to lower case.
487positions yes Record positions of source code expressions.
488copy no Copy source code expressions.
489guile> (debug-options 'help)
490stack 20000 Stack size limit (0 = no check).
07d83abe
MV
491backtrace no Show backtrace on error.
492depth 20 Maximal length of printed backtrace.
07d83abe 493backwards no Display backtrace in anti-chronological order.
07d83abe
MV
494guile> (read-enable 'case-insensitive)
495(keywords #f case-insensitive positions)
496guile> aBc
497"hello"
498guile> (read-disable 'case-insensitive)
499(keywords #f positions)
500guile> (debug-enable 'backtrace)
501(stack 20000 debug backtrace depth 20 maxdepth 1000 frames 3 indent 10 procnames cheap)
502guile> aBc
503
504Backtrace:
5050* aBc
506
507ERROR: In expression aBc:
508ERROR: Unbound variable: aBc
509ABORT: (misc-error)
510guile>
511@end smalllisp
512
513
514@c Local Variables:
515@c TeX-master: "guile.texi"
516@c End: