api-options.texi 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. @c -*-texinfo-*-
  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
  4. @c Free Software Foundation, Inc.
  5. @c See the file guile.texi for copying conditions.
  6. @page
  7. @node Options and Config
  8. @section Configuration, Features and Runtime Options
  9. Why is my Guile different from your Guile? There are three kinds of
  10. possible variation:
  11. @itemize @bullet
  12. @item
  13. build differences --- different versions of the Guile source code,
  14. installation directories, configuration flags that control pieces of
  15. functionality being included or left out, etc.
  16. @item
  17. differences in dynamically loaded code --- behaviour and features
  18. provided by modules that can be dynamically loaded into a running Guile
  19. @item
  20. different runtime options --- some of the options that are provided for
  21. controlling Guile's behaviour may be set differently.
  22. @end itemize
  23. Guile provides ``introspective'' variables and procedures to query all
  24. of these possible variations at runtime. For runtime options, it also
  25. provides procedures to change the settings of options and to obtain
  26. documentation on what the options mean.
  27. @menu
  28. * Build Config:: Build and installation configuration.
  29. * Feature Tracking:: Available features in the Guile process.
  30. * Runtime Options:: Controlling Guile's runtime behaviour.
  31. @end menu
  32. @node Build Config
  33. @subsection Configuration, Build and Installation
  34. The following procedures and variables provide information about how
  35. Guile was configured, built and installed on your system.
  36. @deffn {Scheme Procedure} version
  37. @deffnx {Scheme Procedure} effective-version
  38. @deffnx {Scheme Procedure} major-version
  39. @deffnx {Scheme Procedure} minor-version
  40. @deffnx {Scheme Procedure} micro-version
  41. @deffnx {C Function} scm_version ()
  42. @deffnx {C Function} scm_effective_version ()
  43. @deffnx {C Function} scm_major_version ()
  44. @deffnx {C Function} scm_minor_version ()
  45. @deffnx {C Function} scm_micro_version ()
  46. Return a string describing Guile's full version number, effective
  47. version number, major, minor or micro version number, respectively.
  48. The @code{effective-version} function returns the version name that
  49. should remain unchanged during a stable series. Currently that means
  50. that it omits the micro version. The effective version should be used
  51. for items like the versioned share directory name
  52. i.e. @file{/usr/share/guile/1.6/}
  53. @lisp
  54. (version) @result{} "1.6.0"
  55. (effective-version) @result{} "1.6"
  56. (major-version) @result{} "1"
  57. (minor-version) @result{} "6"
  58. (micro-version) @result{} "0"
  59. @end lisp
  60. @end deffn
  61. @deffn {Scheme Procedure} %package-data-dir
  62. @deffnx {C Function} scm_sys_package_data_dir ()
  63. Return the name of the directory under which Guile Scheme files in
  64. general are stored. On Unix-like systems, this is usually
  65. @file{/usr/local/share/guile} or @file{/usr/share/guile}.
  66. @end deffn
  67. @deffn {Scheme Procedure} %library-dir
  68. @deffnx {C Function} scm_sys_library_dir ()
  69. Return the name of the directory where the Guile Scheme files that
  70. belong to the core Guile installation (as opposed to files from a 3rd
  71. party package) are installed. On Unix-like systems, this is usually
  72. @file{/usr/local/share/guile/<GUILE_EFFECTIVE_VERSION>} or
  73. @file{/usr/share/guile/<GUILE_EFFECTIVE_VERSION>}, for example:
  74. @file{/usr/local/share/guile/1.6}.
  75. @end deffn
  76. @deffn {Scheme Procedure} %site-dir
  77. @deffnx {C Function} scm_sys_site_dir ()
  78. Return the name of the directory where Guile Scheme files specific to
  79. your site should be installed. On Unix-like systems, this is usually
  80. @file{/usr/local/share/guile/site} or @file{/usr/share/guile/site}.
  81. @end deffn
  82. @cindex GUILE_LOAD_PATH
  83. @defvar %load-path
  84. List of directories which should be searched for Scheme modules and
  85. libraries. @code{%load-path} is initialized when Guile starts up to
  86. @code{(list (%site-dir) (%library-dir) (%package-data-dir))},
  87. prepended with the contents of the GUILE_LOAD_PATH environment variable,
  88. if it is set.
  89. @end defvar
  90. @deffn {Scheme Procedure} parse-path path [tail]
  91. @deffnx {C Function} scm_parse_path (path, tail)
  92. Parse @var{path}, which is expected to be a colon-separated
  93. string, into a list and return the resulting list with
  94. @var{tail} appended. If @var{path} is @code{#f}, @var{tail}
  95. is returned.
  96. @end deffn
  97. @deffn {Scheme Procedure} search-path path filename [extensions]
  98. @deffnx {C Function} scm_search_path (path, filename, extensions)
  99. Search @var{path} for a directory containing a file named
  100. @var{filename}. The file must be readable, and not a directory.
  101. If we find one, return its full filename; otherwise, return
  102. @code{#f}. If @var{filename} is absolute, return it unchanged.
  103. If given, @var{extensions} is a list of strings; for each
  104. directory in @var{path}, we search for @var{filename}
  105. concatenated with each @var{extension}.
  106. @end deffn
  107. @defvar %guile-build-info
  108. Alist of information collected during the building of a particular
  109. Guile. Entries can be grouped into one of several categories:
  110. directories, env vars, and versioning info.
  111. Briefly, here are the keys in @code{%guile-build-info}, by group:
  112. @cindex @code{srcdir}
  113. @cindex @code{top_srcdir}
  114. @cindex @code{prefix}
  115. @cindex @code{exec_prefix}
  116. @cindex @code{bindir}
  117. @cindex @code{sbindir}
  118. @cindex @code{libexecdir}
  119. @cindex @code{datadir}
  120. @cindex @code{sysconfdir}
  121. @cindex @code{sharedstatedir}
  122. @cindex @code{localstatedir}
  123. @cindex @code{libdir}
  124. @cindex @code{infodir}
  125. @cindex @code{mandir}
  126. @cindex @code{includedir}
  127. @cindex @code{pkgdatadir}
  128. @cindex @code{pkglibdir}
  129. @cindex @code{pkgincludedir}
  130. @table @asis
  131. @item directories
  132. srcdir, top_srcdir, prefix, exec_prefix, bindir, sbindir, libexecdir,
  133. datadir, sysconfdir, sharedstatedir, localstatedir, libdir, infodir,
  134. mandir, includedir, pkgdatadir, pkglibdir, pkgincludedir
  135. @cindex @code{LIBS}
  136. @item env vars
  137. LIBS
  138. @cindex @code{guileversion}
  139. @cindex @code{libguileinterface}
  140. @cindex @code{buildstamp}
  141. @item versioning info
  142. guileversion, libguileinterface, buildstamp
  143. @end table
  144. Values are all strings. The value for @code{LIBS} is typically found
  145. also as a part of "guile-config link" output. The value for
  146. @code{guileversion} has form X.Y.Z, and should be the same as returned
  147. by @code{(version)}. The value for @code{libguileinterface} is
  148. libtool compatible and has form CURRENT:REVISION:AGE
  149. (@pxref{Versioning,, Library interface versions, libtool, GNU
  150. Libtool}). The value for @code{buildstamp} is the output of the
  151. date(1) command.
  152. In the source, @code{%guile-build-info} is initialized from
  153. libguile/libpath.h, which is completely generated, so deleting this file
  154. before a build guarantees up-to-date values for that build.
  155. @end defvar
  156. @node Feature Tracking
  157. @subsection Feature Tracking
  158. Guile has a Scheme level variable @code{*features*} that keeps track to
  159. some extent of the features that are available in a running Guile.
  160. @code{*features*} is a list of symbols, for example @code{threads}, each
  161. of which describes a feature of the running Guile process.
  162. @defvar *features*
  163. A list of symbols describing available features of the Guile process.
  164. @end defvar
  165. You shouldn't modify the @code{*features*} variable directly using
  166. @code{set!}. Instead, see the procedures that are provided for this
  167. purpose in the following subsection.
  168. @menu
  169. * Feature Manipulation:: Checking for and advertising features.
  170. * Common Feature Symbols:: Commonly available features.
  171. @end menu
  172. @node Feature Manipulation
  173. @subsubsection Feature Manipulation
  174. To check whether a particular feature is available, use the
  175. @code{provided?} procedure:
  176. @deffn {Scheme Procedure} provided? feature
  177. @deffnx {Deprecated Scheme Procedure} feature? feature
  178. Return @code{#t} if the specified @var{feature} is available, otherwise
  179. @code{#f}.
  180. @end deffn
  181. To advertise a feature from your own Scheme code, you can use the
  182. @code{provide} procedure:
  183. @deffn {Scheme Procedure} provide feature
  184. Add @var{feature} to the list of available features in this Guile
  185. process.
  186. @end deffn
  187. For C code, the equivalent function takes its feature name as a
  188. @code{char *} argument for convenience:
  189. @deftypefn {C Function} void scm_add_feature (const char *str)
  190. Add a symbol with name @var{str} to the list of available features in
  191. this Guile process.
  192. @end deftypefn
  193. @node Common Feature Symbols
  194. @subsubsection Common Feature Symbols
  195. In general, a particular feature may be available for one of two
  196. reasons. Either because the Guile library was configured and compiled
  197. with that feature enabled --- i.e. the feature is built into the library
  198. on your system. Or because some C or Scheme code that was dynamically
  199. loaded by Guile has added that feature to the list.
  200. In the first category, here are the features that the current version of
  201. Guile may define (depending on how it is built), and what they mean.
  202. @table @code
  203. @item array
  204. Indicates support for arrays (@pxref{Arrays}).
  205. @item array-for-each
  206. Indicates availability of @code{array-for-each} and other array mapping
  207. procedures (@pxref{Arrays}).
  208. @item char-ready?
  209. Indicates that the @code{char-ready?} function is available
  210. (@pxref{Reading}).
  211. @item complex
  212. Indicates support for complex numbers.
  213. @item current-time
  214. Indicates availability of time-related functions: @code{times},
  215. @code{get-internal-run-time} and so on (@pxref{Time}).
  216. @item debug-extensions
  217. Indicates that the debugging evaluator is available, together with the
  218. options for controlling it.
  219. @item delay
  220. Indicates support for promises (@pxref{Delayed Evaluation}).
  221. @item EIDs
  222. Indicates that the @code{geteuid} and @code{getegid} really return
  223. effective user and group IDs (@pxref{Processes}).
  224. @item inexact
  225. Indicates support for inexact numbers.
  226. @item i/o-extensions
  227. Indicates availability of the following extended I/O procedures:
  228. @code{ftell}, @code{redirect-port}, @code{dup->fdes}, @code{dup2},
  229. @code{fileno}, @code{isatty?}, @code{fdopen},
  230. @code{primitive-move->fdes} and @code{fdes->ports} (@pxref{Ports and
  231. File Descriptors}).
  232. @item net-db
  233. Indicates availability of network database functions:
  234. @code{scm_gethost}, @code{scm_getnet}, @code{scm_getproto},
  235. @code{scm_getserv}, @code{scm_sethost}, @code{scm_setnet}, @code{scm_setproto},
  236. @code{scm_setserv}, and their `byXXX' variants (@pxref{Network
  237. Databases}).
  238. @item posix
  239. Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
  240. @code{kill}, @code{execl} and so on (@pxref{POSIX}).
  241. @item random
  242. Indicates availability of random number generation functions:
  243. @code{random}, @code{copy-random-state}, @code{random-uniform} and so on
  244. (@pxref{Random}).
  245. @item reckless
  246. Indicates that Guile was built with important checks omitted --- you
  247. should never see this!
  248. @item regex
  249. Indicates support for POSIX regular expressions using
  250. @code{make-regexp}, @code{regexp-exec} and friends (@pxref{Regexp
  251. Functions}).
  252. @item socket
  253. Indicates availability of socket-related functions: @code{socket},
  254. @code{bind}, @code{connect} and so on (@pxref{Network Sockets and
  255. Communication}).
  256. @item sort
  257. Indicates availability of sorting and merging functions
  258. (@pxref{Sorting}).
  259. @item system
  260. Indicates that the @code{system} function is available
  261. (@pxref{Processes}).
  262. @item threads
  263. Indicates support for multithreading (@pxref{Threads}).
  264. @item values
  265. Indicates support for multiple return values using @code{values} and
  266. @code{call-with-values} (@pxref{Multiple Values}).
  267. @end table
  268. Available features in the second category depend, by definition, on what
  269. additional code your Guile process has loaded in. The following table
  270. lists features that you might encounter for this reason.
  271. @table @code
  272. @item defmacro
  273. Indicates that the @code{defmacro} macro is available (@pxref{Macros}).
  274. @item describe
  275. Indicates that the @code{(oop goops describe)} module has been loaded,
  276. which provides a procedure for describing the contents of GOOPS
  277. instances.
  278. @item readline
  279. Indicates that Guile has loaded in Readline support, for command line
  280. editing (@pxref{Readline Support}).
  281. @item record
  282. Indicates support for record definition using @code{make-record-type}
  283. and friends (@pxref{Records}).
  284. @end table
  285. Although these tables may seem exhaustive, it is probably unwise in
  286. practice to rely on them, as the correspondences between feature symbols
  287. and available procedures/behaviour are not strictly defined. If you are
  288. writing code that needs to check for the existence of some procedure, it
  289. is probably safer to do so directly using the @code{defined?} procedure
  290. than to test for the corresponding feature using @code{provided?}.
  291. @node Runtime Options
  292. @subsection Runtime Options
  293. Guile's runtime behaviour can be modified by setting options. For
  294. example, is the language that Guile accepts case sensitive, or should
  295. the debugger automatically show a backtrace on error?
  296. Guile has two levels of interface for managing options: a low-level
  297. control interface, and a user-level interface which allows the enabling
  298. or disabling of options.
  299. Moreover, the options are classified in groups according to whether they
  300. configure @emph{reading}, @emph{printing}, @emph{debugging} or
  301. @emph{evaluating}.
  302. @menu
  303. * Low level options interfaces::
  304. * User level options interfaces::
  305. * Reader options::
  306. * Printing options::
  307. * Debugger options::
  308. * Evaluator options::
  309. * Evaluator trap options::
  310. * Examples of option use::
  311. @end menu
  312. @node Low level options interfaces
  313. @subsubsection Low Level Options Interfaces
  314. @deffn {Scheme Procedure} read-options-interface [setting]
  315. @deffnx {Scheme Procedure} eval-options-interface [setting]
  316. @deffnx {Scheme Procedure} print-options-interface [setting]
  317. @deffnx {Scheme Procedure} debug-options-interface [setting]
  318. @deffnx {Scheme Procedure} evaluator-traps-interface [setting]
  319. @deffnx {C Function} scm_read_options (setting)
  320. @deffnx {C Function} scm_eval_options_interface (setting)
  321. @deffnx {C Function} scm_print_options (setting)
  322. @deffnx {C Function} scm_debug_options (setting)
  323. @deffnx {C Function} scm_evaluator_traps (setting)
  324. If one of these procedures is called with no arguments (or with
  325. @code{setting == SCM_UNDEFINED} in C code), it returns a list describing
  326. the current setting of the read, eval, print, debug or evaluator traps
  327. options respectively. The setting of a boolean option is indicated
  328. simply by the presence or absence of the option symbol in the list. The
  329. setting of a non-boolean option is indicated by the presence of the
  330. option symbol immediately followed by the option's current value.
  331. If called with a list argument, these procedures interpret the list as
  332. an option setting and modify the relevant options accordingly. [FIXME
  333. --- this glosses over a lot of details!]
  334. If called with any other argument, such as @code{'help}, these
  335. procedures return a list of entries like @code{(@var{OPTION-SYMBOL}
  336. @var{DEFAULT-VALUE} @var{DOC-STRING})}, with each entry giving the
  337. default value and documentation for each option symbol in the relevant
  338. set of options.
  339. @end deffn
  340. @node User level options interfaces
  341. @subsubsection User Level Options Interfaces
  342. @c @deftp {Data type} scm_option
  343. @c @code{scm_option} is used to represent run time options. It can be a
  344. @c @emph{boolean} type, in which case the option will be set by the strings
  345. @c @code{"yes"} and @code{"no"}. It can be a
  346. @c @end deftp
  347. @c NJFIXME
  348. @deffn {Scheme Procedure} <group>-options [arg]
  349. @deffnx {Scheme Procedure} read-options [arg]
  350. @deffnx {Scheme Procedure} print-options [arg]
  351. @deffnx {Scheme Procedure} debug-options [arg]
  352. @deffnx {Scheme Procedure} traps [arg]
  353. These functions list the options in their group. The optional argument
  354. @var{arg} is a symbol which modifies the form in which the options are
  355. presented.
  356. With no arguments, @code{<group>-options} returns the values of the
  357. options in that particular group. If @var{arg} is @code{'help}, a
  358. description of each option is given. If @var{arg} is @code{'full},
  359. programmers' options are also shown.
  360. @var{arg} can also be a list representing the state of all options. In
  361. this case, the list contains single symbols (for enabled boolean
  362. options) and symbols followed by values.
  363. @end deffn
  364. [FIXME: I don't think 'full is ever any different from 'help. What's
  365. up?]
  366. @c NJFIXME
  367. @deffn {Scheme Procedure} <group>-enable option-symbol
  368. @deffnx {Scheme Procedure} read-enable option-symbol
  369. @deffnx {Scheme Procedure} print-enable option-symbol
  370. @deffnx {Scheme Procedure} debug-enable option-symbol
  371. @deffnx {Scheme Procedure} trap-enable option-symbol
  372. These functions set the specified @var{option-symbol} in their options
  373. group. They only work if the option is boolean, and throw an error
  374. otherwise.
  375. @end deffn
  376. @c NJFIXME
  377. @deffn {Scheme Procedure} <group>-disable option-symbol
  378. @deffnx {Scheme Procedure} read-disable option-symbol
  379. @deffnx {Scheme Procedure} print-disable option-symbol
  380. @deffnx {Scheme Procedure} debug-disable option-symbol
  381. @deffnx {Scheme Procedure} trap-disable option-symbol
  382. These functions turn off the specified @var{option-symbol} in their
  383. options group. They only work if the option is boolean, and throw an
  384. error otherwise.
  385. @end deffn
  386. @c NJFIXME
  387. @deffn syntax <group>-set! option-symbol value
  388. @deffnx syntax read-set! option-symbol value
  389. @deffnx syntax print-set! option-symbol value
  390. @deffnx syntax debug-set! option-symbol value
  391. @deffnx syntax trap-set! option-symbol value
  392. These functions set a non-boolean @var{option-symbol} to the specified
  393. @var{value}.
  394. @end deffn
  395. @node Reader options
  396. @subsubsection Reader options
  397. @cindex options - read
  398. @cindex read options
  399. Here is the list of reader options generated by typing
  400. @code{(read-options 'full)} in Guile. You can also see the default
  401. values.
  402. @smalllisp
  403. keywords #f Style of keyword recognition: #f, 'prefix or 'postfix
  404. case-insensitive no Convert symbols to lower case.
  405. positions yes Record positions of source code expressions.
  406. copy no Copy source code expressions.
  407. @end smalllisp
  408. Notice that while Standard Scheme is case insensitive, to ease
  409. translation of other Lisp dialects, notably Emacs Lisp, into Guile,
  410. Guile is case-sensitive by default.
  411. To make Guile case insensitive, you can type
  412. @smalllisp
  413. (read-enable 'case-insensitive)
  414. @end smalllisp
  415. @node Printing options
  416. @subsubsection Printing options
  417. Here is the list of print options generated by typing
  418. @code{(print-options 'full)} in Guile. You can also see the default
  419. values.
  420. @smallexample
  421. quote-keywordish-symbols reader How to print symbols that have a colon
  422. as their first or last character. The
  423. value '#f' does not quote the colons;
  424. '#t' quotes them; 'reader' quotes
  425. them when the reader option
  426. 'keywords' is not '#f'.
  427. highlight-prefix @{ The string to print before highlighted values.
  428. highlight-suffix @} The string to print after highlighted values.
  429. source no Print closures with source.
  430. closure-hook #f Hook for printing closures.
  431. @end smallexample
  432. @node Evaluator options
  433. @subsubsection Evaluator options
  434. These are the evaluator options with their default values, as they are
  435. printed by typing @code{(eval-options 'full)} in Guile.
  436. @smallexample
  437. stack 22000 Size of thread stacks (in machine words).
  438. @end smallexample
  439. @node Evaluator trap options
  440. @subsubsection Evaluator trap options
  441. [FIXME: These flags, together with their corresponding handlers, are not
  442. user level options. Probably this entire section should be moved to the
  443. documentation about the low-level programmer debugging interface.]
  444. Here is the list of evaluator trap options generated by typing
  445. @code{(traps 'full)} in Guile. You can also see the default values.
  446. @smallexample
  447. exit-frame no Trap when exiting eval or apply.
  448. apply-frame no Trap when entering apply.
  449. enter-frame no Trap when eval enters new frame.
  450. traps yes Enable evaluator traps.
  451. @end smallexample
  452. @deffn apply-frame-handler key cont tailp
  453. Called when a procedure is being applied.
  454. Called if:
  455. @itemize @bullet
  456. @item
  457. evaluator traps are enabled [traps interface], and
  458. @item
  459. either
  460. @itemize @minus
  461. @item
  462. @code{apply-frame} is enabled [traps interface], or
  463. @item
  464. trace mode is on [debug-options interface], and the procedure being
  465. called has the trace property enabled.
  466. @end itemize
  467. @end itemize
  468. @var{cont} is a ``debug object'', which means that it can be passed to
  469. @code{make-stack} to discover the stack at the point of the trap. The
  470. apply frame handler's code can capture a restartable continuation if it
  471. wants to by using @code{call-with-current-continuation} in the usual way.
  472. @var{tailp} is true if this is a tail call
  473. @end deffn
  474. @deffn exit-frame-handler key cont retval
  475. Called when a value is returned from a procedure.
  476. Called if:
  477. @itemize @bullet
  478. @item
  479. evaluator traps are enabled [traps interface], and
  480. @item
  481. either
  482. @itemize @minus
  483. @item
  484. @code{exit-frame} is enabled [traps interface], or
  485. @item
  486. trace mode is on [debug-options interface], and the procedure being
  487. called has the trace property enabled.
  488. @end itemize
  489. @end itemize
  490. @var{cont} is a ``debug object'', which means that it can be passed to
  491. @code{make-stack} to discover the stack at the point of the trap. The
  492. exit frame handler's code can capture a restartable continuation if it
  493. wants to by using @code{call-with-current-continuation} in the usual
  494. way.
  495. @var{retval} is the return value.
  496. @end deffn
  497. @deffn {Scheme Procedure} with-traps thunk
  498. @deffnx {C Function} scm_with_traps (thunk)
  499. Call @var{thunk} with traps enabled.
  500. @end deffn
  501. @deffn {Scheme Procedure} debug-object? obj
  502. @deffnx {C Function} scm_debug_object_p (obj)
  503. Return @code{#t} if @var{obj} is a debug object.
  504. @end deffn
  505. @node Debugger options
  506. @subsubsection Debugger options
  507. Here is the list of print options generated by typing
  508. @code{(debug-options 'full)} in Guile. You can also see the default
  509. values.
  510. @smallexample
  511. stack 20000 Stack size limit (0 = no check).
  512. debug yes Use the debugging evaluator.
  513. backtrace no Show backtrace on error.
  514. depth 20 Maximal length of printed backtrace.
  515. maxdepth 1000 Maximal number of stored backtrace frames.
  516. frames 3 Maximum number of tail-recursive frames in backtrace.
  517. indent 10 Maximal indentation in backtrace.
  518. backwards no Display backtrace in anti-chronological order.
  519. procnames yes Record procedure names at definition.
  520. trace no *Trace mode.
  521. breakpoints no *Check for breakpoints.
  522. cheap yes *This option is now obsolete. Setting it has no effect.
  523. @end smallexample
  524. @subsubheading Stack overflow
  525. @cindex overflow, stack
  526. @cindex stack overflow
  527. Stack overflow errors are caused by a computation trying to use more
  528. stack space than has been enabled by the @code{stack} option. They are
  529. reported like this:
  530. @lisp
  531. (non-tail-recursive-factorial 500)
  532. @print{}
  533. ERROR: Stack overflow
  534. ABORT: (stack-overflow)
  535. @end lisp
  536. If you get an error like this, you can either try rewriting your code to
  537. use less stack space, or increase the maximum stack size. To increase
  538. the maximum stack size, use @code{debug-set!}, for example:
  539. @lisp
  540. (debug-set! stack 200000)
  541. @result{}
  542. (show-file-name #t stack 200000 debug backtrace depth 20 maxdepth 1000 frames 3 indent 10 width 79 procnames cheap)
  543. (non-tail-recursive-factorial 500)
  544. @result{}
  545. 122013682599111006870123878542304692625357434@dots{}
  546. @end lisp
  547. If you prefer to try rewriting your code, you may be able to save stack
  548. space by making some of your procedures @dfn{tail recursive}
  549. (@pxref{Tail Calls}).
  550. @node Examples of option use
  551. @subsubsection Examples of option use
  552. Here is an example of a session in which some read and debug option
  553. handling procedures are used. In this example, the user
  554. @enumerate
  555. @item
  556. Notices that the symbols @code{abc} and @code{aBc} are not the same
  557. @item
  558. Examines the @code{read-options}, and sees that @code{case-insensitive}
  559. is set to ``no''.
  560. @item
  561. Enables @code{case-insensitive}
  562. @item
  563. Verifies that now @code{aBc} and @code{abc} are the same
  564. @item
  565. Disables @code{case-insensitive} and enables debugging @code{backtrace}
  566. @item
  567. Reproduces the error of displaying @code{aBc} with backtracing enabled
  568. [FIXME: this last example is lame because there is no depth in the
  569. backtrace. Need to give a better example, possibly putting debugging
  570. option examples in a separate session.]
  571. @end enumerate
  572. @smalllisp
  573. guile> (define abc "hello")
  574. guile> abc
  575. "hello"
  576. guile> aBc
  577. ERROR: In expression aBc:
  578. ERROR: Unbound variable: aBc
  579. ABORT: (misc-error)
  580. Type "(backtrace)" to get more information.
  581. guile> (read-options 'help)
  582. keywords #f Style of keyword recognition: #f, 'prefix or 'postfix
  583. case-insensitive no Convert symbols to lower case.
  584. positions yes Record positions of source code expressions.
  585. copy no Copy source code expressions.
  586. guile> (debug-options 'help)
  587. stack 20000 Stack size limit (0 = no check).
  588. debug yes Use the debugging evaluator.
  589. backtrace no Show backtrace on error.
  590. depth 20 Maximal length of printed backtrace.
  591. maxdepth 1000 Maximal number of stored backtrace frames.
  592. frames 3 Maximum number of tail-recursive frames in backtrace.
  593. indent 10 Maximal indentation in backtrace.
  594. backwards no Display backtrace in anti-chronological order.
  595. procnames yes Record procedure names at definition.
  596. trace no *Trace mode.
  597. breakpoints no *Check for breakpoints.
  598. cheap yes *This option is now obsolete. Setting it has no effect.
  599. guile> (read-enable 'case-insensitive)
  600. (keywords #f case-insensitive positions)
  601. guile> aBc
  602. "hello"
  603. guile> (read-disable 'case-insensitive)
  604. (keywords #f positions)
  605. guile> (debug-enable 'backtrace)
  606. (stack 20000 debug backtrace depth 20 maxdepth 1000 frames 3 indent 10 procnames cheap)
  607. guile> aBc
  608. Backtrace:
  609. 0* aBc
  610. ERROR: In expression aBc:
  611. ERROR: Unbound variable: aBc
  612. ABORT: (misc-error)
  613. guile>
  614. @end smalllisp
  615. @c Local Variables:
  616. @c TeX-master: "guile.texi"
  617. @c End: