2 @c This is part of the GNU Guile Reference Manual.
3 @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010
4 @c Free Software Foundation, Inc.
5 @c See the file guile.texi for copying conditions.
8 @node Options and Config
9 @section Configuration, Features and Runtime Options
11 Why is my Guile different from your Guile? There are three kinds of
16 build differences --- different versions of the Guile source code,
17 installation directories, configuration flags that control pieces of
18 functionality being included or left out, etc.
21 differences in dynamically loaded code --- behaviour and features
22 provided by modules that can be dynamically loaded into a running Guile
25 different runtime options --- some of the options that are provided for
26 controlling Guile's behaviour may be set differently.
29 Guile provides ``introspective'' variables and procedures to query all
30 of these possible variations at runtime. For runtime options, it also
31 provides procedures to change the settings of options and to obtain
32 documentation on what the options mean.
35 * Build Config:: Build and installation configuration.
36 * Feature Tracking:: Available features in the Guile process.
37 * Runtime Options:: Controlling Guile's runtime behaviour.
42 @subsection Configuration, Build and Installation
44 The following procedures and variables provide information about how
45 Guile was configured, built and installed on your system.
47 @deffn {Scheme Procedure} version
48 @deffnx {Scheme Procedure} effective-version
49 @deffnx {Scheme Procedure} major-version
50 @deffnx {Scheme Procedure} minor-version
51 @deffnx {Scheme Procedure} micro-version
52 @deffnx {C Function} scm_version ()
53 @deffnx {C Function} scm_effective_version ()
54 @deffnx {C Function} scm_major_version ()
55 @deffnx {C Function} scm_minor_version ()
56 @deffnx {C Function} scm_micro_version ()
57 Return a string describing Guile's full version number, effective
58 version number, major, minor or micro version number, respectively.
59 The @code{effective-version} function returns the version name that
60 should remain unchanged during a stable series. Currently that means
61 that it omits the micro version. The effective version should be used
62 for items like the versioned share directory name
63 i.e. @file{/usr/share/guile/1.6/}
66 (version) @result{} "1.6.0"
67 (effective-version) @result{} "1.6"
68 (major-version) @result{} "1"
69 (minor-version) @result{} "6"
70 (micro-version) @result{} "0"
74 @deffn {Scheme Procedure} %package-data-dir
75 @deffnx {C Function} scm_sys_package_data_dir ()
76 Return the name of the directory under which Guile Scheme files in
77 general are stored. On Unix-like systems, this is usually
78 @file{/usr/local/share/guile} or @file{/usr/share/guile}.
81 @deffn {Scheme Procedure} %library-dir
82 @deffnx {C Function} scm_sys_library_dir ()
83 Return the name of the directory where the Guile Scheme files that
84 belong to the core Guile installation (as opposed to files from a 3rd
85 party package) are installed. On Unix-like systems this is usually
86 @file{/usr/local/share/guile/<GUILE_EFFECTIVE_VERSION>} or
87 @file{/usr/share/guile/<GUILE_EFFECTIVE_VERSION>};
89 @noindent for example @file{/usr/local/share/guile/1.6}.
92 @deffn {Scheme Procedure} %site-dir
93 @deffnx {C Function} scm_sys_site_dir ()
94 Return the name of the directory where Guile Scheme files specific to
95 your site should be installed. On Unix-like systems, this is usually
96 @file{/usr/local/share/guile/site} or @file{/usr/share/guile/site}.
99 @cindex GUILE_LOAD_PATH
101 List of directories which should be searched for Scheme modules and
102 libraries. @code{%load-path} is initialized when Guile starts up to
103 @code{(list (%site-dir) (%library-dir) (%package-data-dir))},
104 prepended with the contents of the GUILE_LOAD_PATH environment variable,
108 @deffn {Scheme Procedure} parse-path path [tail]
109 @deffnx {C Function} scm_parse_path (path, tail)
110 Parse @var{path}, which is expected to be a colon-separated
111 string, into a list and return the resulting list with
112 @var{tail} appended. If @var{path} is @code{#f}, @var{tail}
116 @deffn {Scheme Procedure} search-path path filename [extensions [require-exts?]]
117 @deffnx {C Function} scm_search_path (path, filename, rest)
118 Search @var{path} for a directory containing a file named
119 @var{filename}. The file must be readable, and not a directory.
120 If we find one, return its full filename; otherwise, return
121 @code{#f}. If @var{filename} is absolute, return it unchanged.
122 If given, @var{extensions} is a list of strings; for each
123 directory in @var{path}, we search for @var{filename}
124 concatenated with each @var{extension}. If @var{require-exts?}
125 is true, require that the returned file name have one of the
126 given extensions; if @var{require-exts?} is not given, it
127 defaults to @code{#f}.
129 For compatibility with Guile 1.8 and earlier, the C function takes only
133 @defvar %guile-build-info
134 Alist of information collected during the building of a particular
135 Guile. Entries can be grouped into one of several categories:
136 directories, env vars, and versioning info.
138 Briefly, here are the keys in @code{%guile-build-info}, by group:
140 @cindex @code{srcdir}
141 @cindex @code{top_srcdir}
142 @cindex @code{prefix}
143 @cindex @code{exec_prefix}
144 @cindex @code{bindir}
145 @cindex @code{sbindir}
146 @cindex @code{libexecdir}
147 @cindex @code{datadir}
148 @cindex @code{sysconfdir}
149 @cindex @code{sharedstatedir}
150 @cindex @code{localstatedir}
151 @cindex @code{libdir}
152 @cindex @code{infodir}
153 @cindex @code{mandir}
154 @cindex @code{includedir}
155 @cindex @code{pkgdatadir}
156 @cindex @code{pkglibdir}
157 @cindex @code{pkgincludedir}
160 srcdir, top_srcdir, prefix, exec_prefix, bindir, sbindir, libexecdir,
161 datadir, sysconfdir, sharedstatedir, localstatedir, libdir, infodir,
162 mandir, includedir, pkgdatadir, pkglibdir, pkgincludedir
166 @cindex @code{guileversion}
167 @cindex @code{libguileinterface}
168 @cindex @code{buildstamp}
169 @item versioning info
170 guileversion, libguileinterface, buildstamp
173 Values are all strings. The value for @code{LIBS} is typically found
174 also as a part of "guile-config link" output. The value for
175 @code{guileversion} has form X.Y.Z, and should be the same as returned
176 by @code{(version)}. The value for @code{libguileinterface} is
177 libtool compatible and has form CURRENT:REVISION:AGE
178 (@pxref{Versioning,, Library interface versions, libtool, GNU
179 Libtool}). The value for @code{buildstamp} is the output of the
182 In the source, @code{%guile-build-info} is initialized from
183 libguile/libpath.h, which is completely generated, so deleting this file
184 before a build guarantees up-to-date values for that build.
188 @cindex canonical host type
191 The canonical host type (GNU triplet) of the host Guile was configured
192 for, e.g., @code{"x86_64-unknown-linux-gnu"} (@pxref{Canonicalizing,,,
193 autoconf, The GNU Autoconf Manual}).
196 @node Feature Tracking
197 @subsection Feature Tracking
199 Guile has a Scheme level variable @code{*features*} that keeps track to
200 some extent of the features that are available in a running Guile.
201 @code{*features*} is a list of symbols, for example @code{threads}, each
202 of which describes a feature of the running Guile process.
205 A list of symbols describing available features of the Guile process.
208 You shouldn't modify the @code{*features*} variable directly using
209 @code{set!}. Instead, see the procedures that are provided for this
210 purpose in the following subsection.
213 * Feature Manipulation:: Checking for and advertising features.
214 * Common Feature Symbols:: Commonly available features.
218 @node Feature Manipulation
219 @subsubsection Feature Manipulation
221 To check whether a particular feature is available, use the
222 @code{provided?} procedure:
224 @deffn {Scheme Procedure} provided? feature
225 @deffnx {Deprecated Scheme Procedure} feature? feature
226 Return @code{#t} if the specified @var{feature} is available, otherwise
230 To advertise a feature from your own Scheme code, you can use the
231 @code{provide} procedure:
233 @deffn {Scheme Procedure} provide feature
234 Add @var{feature} to the list of available features in this Guile
238 For C code, the equivalent function takes its feature name as a
239 @code{char *} argument for convenience:
241 @deftypefn {C Function} void scm_add_feature (const char *str)
242 Add a symbol with name @var{str} to the list of available features in
247 @node Common Feature Symbols
248 @subsubsection Common Feature Symbols
250 In general, a particular feature may be available for one of two
251 reasons. Either because the Guile library was configured and compiled
252 with that feature enabled --- i.e. the feature is built into the library
253 on your system. Or because some C or Scheme code that was dynamically
254 loaded by Guile has added that feature to the list.
256 In the first category, here are the features that the current version of
257 Guile may define (depending on how it is built), and what they mean.
261 Indicates support for arrays (@pxref{Arrays}).
264 Indicates availability of @code{array-for-each} and other array mapping
265 procedures (@pxref{Arrays}).
268 Indicates that the @code{char-ready?} function is available
272 Indicates support for complex numbers.
275 Indicates availability of time-related functions: @code{times},
276 @code{get-internal-run-time} and so on (@pxref{Time}).
278 @item debug-extensions
279 Indicates that the debugging evaluator is available, together with the
280 options for controlling it.
283 Indicates support for promises (@pxref{Delayed Evaluation}).
286 Indicates that the @code{geteuid} and @code{getegid} really return
287 effective user and group IDs (@pxref{Processes}).
290 Indicates support for inexact numbers.
293 Indicates availability of the following extended I/O procedures:
294 @code{ftell}, @code{redirect-port}, @code{dup->fdes}, @code{dup2},
295 @code{fileno}, @code{isatty?}, @code{fdopen},
296 @code{primitive-move->fdes} and @code{fdes->ports} (@pxref{Ports and
300 Indicates availability of network database functions:
301 @code{scm_gethost}, @code{scm_getnet}, @code{scm_getproto},
302 @code{scm_getserv}, @code{scm_sethost}, @code{scm_setnet}, @code{scm_setproto},
303 @code{scm_setserv}, and their `byXXX' variants (@pxref{Network
307 Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
308 @code{kill}, @code{execl} and so on (@pxref{POSIX}).
311 Indicates availability of random number generation functions:
312 @code{random}, @code{copy-random-state}, @code{random-uniform} and so on
316 Indicates that Guile was built with important checks omitted --- you
317 should never see this!
320 Indicates support for POSIX regular expressions using
321 @code{make-regexp}, @code{regexp-exec} and friends (@pxref{Regexp
325 Indicates availability of socket-related functions: @code{socket},
326 @code{bind}, @code{connect} and so on (@pxref{Network Sockets and
330 Indicates availability of sorting and merging functions
334 Indicates that the @code{system} function is available
338 Indicates support for multithreading (@pxref{Threads}).
341 Indicates support for multiple return values using @code{values} and
342 @code{call-with-values} (@pxref{Multiple Values}).
345 Available features in the second category depend, by definition, on what
346 additional code your Guile process has loaded in. The following table
347 lists features that you might encounter for this reason.
351 Indicates that the @code{defmacro} macro is available (@pxref{Macros}).
354 Indicates that the @code{(oop goops describe)} module has been loaded,
355 which provides a procedure for describing the contents of GOOPS
359 Indicates that Guile has loaded in Readline support, for command line
360 editing (@pxref{Readline Support}).
363 Indicates support for record definition using @code{make-record-type}
364 and friends (@pxref{Records}).
367 Although these tables may seem exhaustive, it is probably unwise in
368 practice to rely on them, as the correspondences between feature symbols
369 and available procedures/behaviour are not strictly defined. If you are
370 writing code that needs to check for the existence of some procedure, it
371 is probably safer to do so directly using the @code{defined?} procedure
372 than to test for the corresponding feature using @code{provided?}.
375 @node Runtime Options
376 @subsection Runtime Options
378 Guile's runtime behaviour can be modified by setting options. For
379 example, is the language that Guile accepts case sensitive, or should
380 the debugger automatically show a backtrace on error?
382 Guile has two levels of interface for managing options: a low-level
383 control interface, and a user-level interface which allows the enabling
384 or disabling of options.
386 Moreover, the options are classified in groups according to whether they
387 configure @emph{reading}, @emph{printing}, @emph{debugging} or
391 * Low level options interfaces::
392 * User level options interfaces::
396 * Evaluator options::
397 * Evaluator trap options::
398 * Examples of option use::
402 @node Low level options interfaces
403 @subsubsection Low Level Options Interfaces
405 @deffn {Scheme Procedure} read-options-interface [setting]
406 @deffnx {Scheme Procedure} eval-options-interface [setting]
407 @deffnx {Scheme Procedure} print-options-interface [setting]
408 @deffnx {Scheme Procedure} debug-options-interface [setting]
409 @deffnx {Scheme Procedure} evaluator-traps-interface [setting]
410 @deffnx {C Function} scm_read_options (setting)
411 @deffnx {C Function} scm_eval_options_interface (setting)
412 @deffnx {C Function} scm_print_options (setting)
413 @deffnx {C Function} scm_debug_options (setting)
414 @deffnx {C Function} scm_evaluator_traps (setting)
415 If one of these procedures is called with no arguments (or with
416 @code{setting == SCM_UNDEFINED} in C code), it returns a list describing
417 the current setting of the read, eval, print, debug or evaluator traps
418 options respectively. The setting of a boolean option is indicated
419 simply by the presence or absence of the option symbol in the list. The
420 setting of a non-boolean option is indicated by the presence of the
421 option symbol immediately followed by the option's current value.
423 If called with a list argument, these procedures interpret the list as
424 an option setting and modify the relevant options accordingly. [FIXME
425 --- this glosses over a lot of details!]
427 If called with any other argument, such as @code{'help}, these
428 procedures return a list of entries like @code{(@var{OPTION-SYMBOL}
429 @var{DEFAULT-VALUE} @var{DOC-STRING})}, with each entry giving the
430 default value and documentation for each option symbol in the relevant
435 @node User level options interfaces
436 @subsubsection User Level Options Interfaces
438 @c @deftp {Data type} scm_option
439 @c @code{scm_option} is used to represent run time options. It can be a
440 @c @emph{boolean} type, in which case the option will be set by the strings
441 @c @code{"yes"} and @code{"no"}. It can be a
445 @deffn {Scheme Procedure} <group>-options [arg]
446 @deffnx {Scheme Procedure} read-options [arg]
447 @deffnx {Scheme Procedure} print-options [arg]
448 @deffnx {Scheme Procedure} debug-options [arg]
449 @deffnx {Scheme Procedure} traps [arg]
450 These functions list the options in their group. The optional argument
451 @var{arg} is a symbol which modifies the form in which the options are
454 With no arguments, @code{<group>-options} returns the values of the
455 options in that particular group. If @var{arg} is @code{'help}, a
456 description of each option is given. If @var{arg} is @code{'full},
457 programmers' options are also shown.
459 @var{arg} can also be a list representing the state of all options. In
460 this case, the list contains single symbols (for enabled boolean
461 options) and symbols followed by values.
463 [FIXME: I don't think 'full is ever any different from 'help. What's
467 @deffn {Scheme Procedure} <group>-enable option-symbol
468 @deffnx {Scheme Procedure} read-enable option-symbol
469 @deffnx {Scheme Procedure} print-enable option-symbol
470 @deffnx {Scheme Procedure} debug-enable option-symbol
471 @deffnx {Scheme Procedure} trap-enable option-symbol
472 These functions set the specified @var{option-symbol} in their options
473 group. They only work if the option is boolean, and throw an error
478 @deffn {Scheme Procedure} <group>-disable option-symbol
479 @deffnx {Scheme Procedure} read-disable option-symbol
480 @deffnx {Scheme Procedure} print-disable option-symbol
481 @deffnx {Scheme Procedure} debug-disable option-symbol
482 @deffnx {Scheme Procedure} trap-disable option-symbol
483 These functions turn off the specified @var{option-symbol} in their
484 options group. They only work if the option is boolean, and throw an
489 @deffn syntax <group>-set! option-symbol value
490 @deffnx syntax read-set! option-symbol value
491 @deffnx syntax print-set! option-symbol value
492 @deffnx syntax debug-set! option-symbol value
493 @deffnx syntax trap-set! option-symbol value
494 These functions set a non-boolean @var{option-symbol} to the specified
500 @subsubsection Reader options
501 @cindex options - read
504 Here is the list of reader options generated by typing
505 @code{(read-options 'full)} in Guile. You can also see the default
509 keywords #f Style of keyword recognition: #f, 'prefix or 'postfix
510 case-insensitive no Convert symbols to lower case.
511 positions yes Record positions of source code expressions.
512 copy no Copy source code expressions.
513 r6rs-hex-escapes no Use R6RS-style string and character hex escapes
516 Notice that while Standard Scheme is case insensitive, to ease
517 translation of other Lisp dialects, notably Emacs Lisp, into Guile,
518 Guile is case-sensitive by default.
520 To make Guile case insensitive, you can type
523 (read-enable 'case-insensitive)
526 For more information on the effect of the @code{r6rs-hex-escapes} option, see
527 (@pxref{Characters}) and (@pxref{String Syntax}).
529 @node Printing options
530 @subsubsection Printing options
532 Here is the list of print options generated by typing
533 @code{(print-options 'full)} in Guile. You can also see the default
537 quote-keywordish-symbols reader How to print symbols that have a colon
538 as their first or last character. The
539 value '#f' does not quote the colons;
540 '#t' quotes them; 'reader' quotes
541 them when the reader option
542 'keywords' is not '#f'.
544 highlight-prefix @{ The string to print before highlighted values.
545 highlight-suffix @} The string to print after highlighted values.
547 source no Print closures with source.
548 closure-hook #f Hook for printing closures.
552 @node Evaluator options
553 @subsubsection Evaluator options
555 These are the evaluator options with their default values, as they are
556 printed by typing @code{(eval-options 'full)} in Guile.
559 stack 22000 Size of thread stacks (in machine words).
563 @node Evaluator trap options
564 @subsubsection Evaluator trap options
565 [FIXME: These flags, together with their corresponding handlers, are not
566 user level options. Probably this entire section should be moved to the
567 documentation about the low-level programmer debugging interface.]
569 Here is the list of evaluator trap options generated by typing
570 @code{(traps 'full)} in Guile. You can also see the default values.
573 exit-frame no Trap when exiting eval or apply.
574 apply-frame no Trap when entering apply.
575 enter-frame no Trap when eval enters new frame.
576 memoize-symbol no Trap when eval memoizes a symbol's value
577 traps yes Enable evaluator traps.
580 @deffn apply-frame-handler key cont tailp
581 Called when a procedure is being applied.
587 evaluator traps are enabled [traps interface], and
592 @code{apply-frame} is enabled [traps interface], or
594 trace mode is on [debug-options interface], and the procedure being
595 called has the trace property enabled.
599 @var{cont} is a ``debug object'', which means that it can be passed to
600 @code{make-stack} to discover the stack at the point of the trap. The
601 apply frame handler's code can capture a restartable continuation if it
602 wants to by using @code{call-with-current-continuation} in the usual way.
604 @var{tailp} is true if this is a tail call
607 @deffn exit-frame-handler key cont retval
608 Called when a value is returned from a procedure.
614 evaluator traps are enabled [traps interface], and
619 @code{exit-frame} is enabled [traps interface], or
621 trace mode is on [debug-options interface], and the procedure being
622 called has the trace property enabled.
626 @var{cont} is a ``debug object'', which means that it can be passed to
627 @code{make-stack} to discover the stack at the point of the trap. The
628 exit frame handler's code can capture a restartable continuation if it
629 wants to by using @code{call-with-current-continuation} in the usual
632 @var{retval} is the return value.
635 @deffn memoize-symbol-handler key cont expression env
636 Called when the evaluator memoizes the value of a procedure symbol
638 @var{cont} is a ``debug object'', which means that it can be passed to
639 @code{make-stack} to discover the stack at the point of the trap. The
640 exit frame handler's code can capture a restartable continuation if it
641 wants to by using @code{call-with-current-continuation} in the usual
644 @var{retval} is the return value.
647 @deffn {Scheme Procedure} with-traps thunk
648 @deffnx {C Function} scm_with_traps (thunk)
649 Call @var{thunk} with traps enabled.
652 @deffn {Scheme Procedure} debug-object? obj
653 @deffnx {C Function} scm_debug_object_p (obj)
654 Return @code{#t} if @var{obj} is a debug object.
658 @node Debugger options
659 @subsubsection Debugger options
661 Here is the list of print options generated by typing
662 @code{(debug-options 'full)} in Guile. You can also see the default
666 stack 20000 Stack size limit (0 = no check).
667 debug yes Use the debugging evaluator.
668 backtrace no Show backtrace on error.
669 depth 20 Maximal length of printed backtrace.
670 maxdepth 1000 Maximal number of stored backtrace frames.
671 frames 3 Maximum number of tail-recursive frames in backtrace.
672 indent 10 Maximal indentation in backtrace.
673 backwards no Display backtrace in anti-chronological order.
674 procnames yes Record procedure names at definition.
675 trace no *Trace mode.
676 breakpoints no *Check for breakpoints.
677 cheap yes *This option is now obsolete. Setting it has no effect.
680 @subsubheading Stack overflow
682 @cindex overflow, stack
683 @cindex stack overflow
684 Stack overflow errors are caused by a computation trying to use more
685 stack space than has been enabled by the @code{stack} option. They are
689 (non-tail-recursive-factorial 500)
691 ERROR: Stack overflow
692 ABORT: (stack-overflow)
695 If you get an error like this, you can either try rewriting your code to
696 use less stack space, or increase the maximum stack size. To increase
697 the maximum stack size, use @code{debug-set!}, for example:
700 (debug-set! stack 200000)
702 (show-file-name #t stack 200000 debug backtrace depth 20
703 maxdepth 1000 frames 3 indent 10 width 79 procnames cheap)
705 (non-tail-recursive-factorial 500)
707 122013682599111006870123878542304692625357434@dots{}
710 If you prefer to try rewriting your code, you may be able to save stack
711 space by making some of your procedures @dfn{tail recursive}
712 (@pxref{Tail Calls}).
715 @node Examples of option use
716 @subsubsection Examples of option use
718 Here is an example of a session in which some read and debug option
719 handling procedures are used. In this example, the user
723 Notices that the symbols @code{abc} and @code{aBc} are not the same
725 Examines the @code{read-options}, and sees that @code{case-insensitive}
728 Enables @code{case-insensitive}
730 Verifies that now @code{aBc} and @code{abc} are the same
732 Disables @code{case-insensitive} and enables debugging @code{backtrace}
734 Reproduces the error of displaying @code{aBc} with backtracing enabled
735 [FIXME: this last example is lame because there is no depth in the
736 backtrace. Need to give a better example, possibly putting debugging
737 option examples in a separate session.]
741 guile> (define abc "hello")
745 ERROR: In expression aBc:
746 ERROR: Unbound variable: aBc
749 Type "(backtrace)" to get more information.
750 guile> (read-options 'help)
751 keywords #f Style of keyword recognition: #f, 'prefix or 'postfix
752 case-insensitive no Convert symbols to lower case.
753 positions yes Record positions of source code expressions.
754 copy no Copy source code expressions.
755 guile> (debug-options 'help)
756 stack 20000 Stack size limit (0 = no check).
757 debug yes Use the debugging evaluator.
758 backtrace no Show backtrace on error.
759 depth 20 Maximal length of printed backtrace.
760 maxdepth 1000 Maximal number of stored backtrace frames.
761 frames 3 Maximum number of tail-recursive frames in backtrace.
762 indent 10 Maximal indentation in backtrace.
763 backwards no Display backtrace in anti-chronological order.
764 procnames yes Record procedure names at definition.
765 trace no *Trace mode.
766 breakpoints no *Check for breakpoints.
767 cheap yes *This option is now obsolete. Setting it has no effect.
768 guile> (read-enable 'case-insensitive)
769 (keywords #f case-insensitive positions)
772 guile> (read-disable 'case-insensitive)
773 (keywords #f positions)
774 guile> (debug-enable 'backtrace)
775 (stack 20000 debug backtrace depth 20 maxdepth 1000 frames 3 indent 10 procnames cheap)
781 ERROR: In expression aBc:
782 ERROR: Unbound variable: aBc
789 @c TeX-master: "guile.texi"