api-options.texi 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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,
  4. @c 2008, 2009, 2010, 2011, 2012, 2013
  5. @c Free Software Foundation, Inc.
  6. @c See the file guile.texi for copying conditions.
  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/3.0/}
  53. @lisp
  54. (version) @result{} "3.0.0"
  55. (effective-version) @result{} "3.0"
  56. (major-version) @result{} "3"
  57. (minor-version) @result{} "0"
  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/@var{GUILE_EFFECTIVE_VERSION}} or
  73. @file{/usr/share/guile/@var{GUILE_EFFECTIVE_VERSION}};
  74. @noindent
  75. for example @file{/usr/local/share/guile/3.0}.
  76. @end deffn
  77. @deffn {Scheme Procedure} %site-dir
  78. @deffnx {C Function} scm_sys_site_dir ()
  79. Return the name of the directory where Guile Scheme files specific to
  80. your site should be installed. On Unix-like systems, this is usually
  81. @file{/usr/local/share/guile/site} or @file{/usr/share/guile/site}.
  82. @end deffn
  83. @deffn {Scheme Procedure} %site-ccache-dir
  84. @deffnx {C Function} scm_sys_site_ccache_dir ()
  85. Return the directory where users should install compiled @code{.go}
  86. files for use with this version of Guile. Might look something like
  87. @file{/usr/lib/guile/@value{EFFECTIVE-VERSION}/site-ccache}.
  88. @end deffn
  89. @defvar %guile-build-info
  90. Alist of information collected during the building of a particular
  91. Guile. Entries can be grouped into one of several categories:
  92. directories, env vars, and versioning info.
  93. Briefly, here are the keys in @code{%guile-build-info}, by group:
  94. @cindex @code{srcdir}
  95. @cindex @code{top_srcdir}
  96. @cindex @code{prefix}
  97. @cindex @code{exec_prefix}
  98. @cindex @code{bindir}
  99. @cindex @code{sbindir}
  100. @cindex @code{libexecdir}
  101. @cindex @code{datadir}
  102. @cindex @code{sysconfdir}
  103. @cindex @code{sharedstatedir}
  104. @cindex @code{localstatedir}
  105. @cindex @code{libdir}
  106. @cindex @code{infodir}
  107. @cindex @code{mandir}
  108. @cindex @code{includedir}
  109. @cindex @code{pkgdatadir}
  110. @cindex @code{pkglibdir}
  111. @cindex @code{pkgincludedir}
  112. @table @asis
  113. @item directories
  114. srcdir, top_srcdir, prefix, exec_prefix, bindir, sbindir, libexecdir,
  115. datadir, sysconfdir, sharedstatedir, localstatedir, libdir, infodir,
  116. mandir, includedir, pkgdatadir, pkglibdir, pkgincludedir
  117. @cindex @code{LIBS}
  118. @item env vars
  119. LIBS
  120. @cindex @code{guileversion}
  121. @cindex @code{libguileinterface}
  122. @cindex @code{buildstamp}
  123. @item versioning info
  124. guileversion, libguileinterface, buildstamp
  125. @end table
  126. Values are all strings. The value for @code{LIBS} is typically found
  127. also as a part of @code{pkg-config --libs
  128. guile-@value{EFFECTIVE-VERSION}} output. The value for
  129. @code{guileversion} has form X.Y.Z, and should be the same as returned
  130. by @code{(version)}. The value for @code{libguileinterface} is libtool
  131. compatible and has form CURRENT:REVISION:AGE (@pxref{Versioning,,
  132. Library interface versions, libtool, GNU Libtool}). The value for
  133. @code{buildstamp} is the output of the command @samp{date -u +'%Y-%m-%d
  134. %T'} (UTC).
  135. In the source, @code{%guile-build-info} is initialized from
  136. libguile/libpath.h, which is completely generated, so deleting this file
  137. before a build guarantees up-to-date values for that build.
  138. @end defvar
  139. @cindex GNU triplet
  140. @cindex canonical host type
  141. @defvar %host-type
  142. The canonical host type (GNU triplet) of the host Guile was configured
  143. for, e.g., @code{"x86_64-unknown-linux-gnu"} (@pxref{Canonicalizing,,,
  144. autoconf, The GNU Autoconf Manual}).
  145. @end defvar
  146. @node Feature Tracking
  147. @subsection Feature Tracking
  148. Guile has a Scheme level variable @code{*features*} that keeps track to
  149. some extent of the features that are available in a running Guile.
  150. @code{*features*} is a list of symbols, for example @code{threads}, each
  151. of which describes a feature of the running Guile process.
  152. @defvar *features*
  153. A list of symbols describing available features of the Guile process.
  154. @end defvar
  155. You shouldn't modify the @code{*features*} variable directly using
  156. @code{set!}. Instead, see the procedures that are provided for this
  157. purpose in the following subsection.
  158. @menu
  159. * Feature Manipulation:: Checking for and advertising features.
  160. * Common Feature Symbols:: Commonly available features.
  161. @end menu
  162. @node Feature Manipulation
  163. @subsubsection Feature Manipulation
  164. To check whether a particular feature is available, use the
  165. @code{provided?} procedure:
  166. @deffn {Scheme Procedure} provided? feature
  167. @deffnx {Deprecated Scheme Procedure} feature? feature
  168. Return @code{#t} if the specified @var{feature} is available, otherwise
  169. @code{#f}.
  170. @end deffn
  171. To advertise a feature from your own Scheme code, you can use the
  172. @code{provide} procedure:
  173. @deffn {Scheme Procedure} provide feature
  174. Add @var{feature} to the list of available features in this Guile
  175. process.
  176. @end deffn
  177. For C code, the equivalent function takes its feature name as a
  178. @code{char *} argument for convenience:
  179. @deftypefn {C Function} void scm_add_feature (const char *str)
  180. Add a symbol with name @var{str} to the list of available features in
  181. this Guile process.
  182. @end deftypefn
  183. @node Common Feature Symbols
  184. @subsubsection Common Feature Symbols
  185. In general, a particular feature may be available for one of two
  186. reasons. Either because the Guile library was configured and compiled
  187. with that feature enabled --- i.e.@: the feature is built into the library
  188. on your system. Or because some C or Scheme code that was dynamically
  189. loaded by Guile has added that feature to the list.
  190. In the first category, here are the features that the current version of
  191. Guile may define (depending on how it is built), and what they mean.
  192. @table @code
  193. @item array
  194. Indicates support for arrays (@pxref{Arrays}).
  195. @item array-for-each
  196. Indicates availability of @code{array-for-each} and other array mapping
  197. procedures (@pxref{Arrays}).
  198. @item char-ready?
  199. Indicates that the @code{char-ready?} function is available
  200. (@pxref{Venerable Port Interfaces}).
  201. @item complex
  202. Indicates support for complex numbers.
  203. @item current-time
  204. Indicates availability of time-related functions: @code{times},
  205. @code{get-internal-run-time} and so on (@pxref{Time}).
  206. @item debug-extensions
  207. Indicates that the debugging evaluator is available, together with the
  208. options for controlling it.
  209. @item delay
  210. Indicates support for promises (@pxref{Delayed Evaluation}).
  211. @item EIDs
  212. Indicates that the @code{geteuid} and @code{getegid} really return
  213. effective user and group IDs (@pxref{Processes}).
  214. @item inexact
  215. Indicates support for inexact numbers.
  216. @item i/o-extensions
  217. Indicates availability of the following extended I/O procedures:
  218. @code{ftell}, @code{redirect-port}, @code{dup->fdes}, @code{dup2},
  219. @code{fileno}, @code{isatty?}, @code{fdopen},
  220. @code{primitive-move->fdes} and @code{fdes->ports} (@pxref{Ports and
  221. File Descriptors}).
  222. @item net-db
  223. Indicates availability of network database functions:
  224. @code{scm_gethost}, @code{scm_getnet}, @code{scm_getproto},
  225. @code{scm_getserv}, @code{scm_sethost}, @code{scm_setnet}, @code{scm_setproto},
  226. @code{scm_setserv}, and their `byXXX' variants (@pxref{Network
  227. Databases}).
  228. @item posix
  229. Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
  230. @code{kill}, @code{execl} and so on (@pxref{POSIX}).
  231. @item fork
  232. Indicates support for the POSIX @code{fork} function (@pxref{Processes,
  233. @code{primitive-fork}}).
  234. @item popen
  235. Indicates support for @code{open-pipe} in the @code{(ice-9 popen)}
  236. module (@pxref{Pipes}).
  237. @item random
  238. Indicates availability of random number generation functions:
  239. @code{random}, @code{copy-random-state}, @code{random-uniform} and so on
  240. (@pxref{Random}).
  241. @item reckless
  242. Indicates that Guile was built with important checks omitted --- you
  243. should never see this!
  244. @item regex
  245. Indicates support for POSIX regular expressions using
  246. @code{make-regexp}, @code{regexp-exec} and friends (@pxref{Regexp
  247. Functions}).
  248. @item socket
  249. Indicates availability of socket-related functions: @code{socket},
  250. @code{bind}, @code{connect} and so on (@pxref{Network Sockets and
  251. Communication}).
  252. @item sort
  253. Indicates availability of sorting and merging functions
  254. (@pxref{Sorting}).
  255. @item system
  256. Indicates that the @code{system} function is available
  257. (@pxref{Processes}).
  258. @item threads
  259. Indicates support for multithreading (@pxref{Threads}).
  260. @item values
  261. Indicates support for multiple return values using @code{values} and
  262. @code{call-with-values} (@pxref{Multiple Values}).
  263. @end table
  264. Available features in the second category depend, by definition, on what
  265. additional code your Guile process has loaded in. The following table
  266. lists features that you might encounter for this reason.
  267. @table @code
  268. @item defmacro
  269. Indicates that the @code{defmacro} macro is available (@pxref{Macros}).
  270. @item describe
  271. Indicates that the @code{(oop goops describe)} module has been loaded,
  272. which provides a procedure for describing the contents of GOOPS
  273. instances.
  274. @item readline
  275. Indicates that Guile has loaded in Readline support, for command line
  276. editing (@pxref{Readline Support}).
  277. @item record
  278. Indicates support for record definition using @code{make-record-type}
  279. and friends (@pxref{Records}).
  280. @end table
  281. Although these tables may seem exhaustive, it is probably unwise in
  282. practice to rely on them, as the correspondences between feature symbols
  283. and available procedures/behaviour are not strictly defined. If you are
  284. writing code that needs to check for the existence of some procedure, it
  285. is probably safer to do so directly using the @code{defined?} procedure
  286. than to test for the corresponding feature using @code{provided?}.
  287. @node Runtime Options
  288. @subsection Runtime Options
  289. There are a number of runtime options available for paramaterizing
  290. built-in procedures, like @code{read}, and built-in behavior, like what
  291. happens on an uncaught error.
  292. For more information on reader options, @xref{Scheme Read}.
  293. For more information on print options, @xref{Scheme Write}.
  294. Finally, for more information on debugger options, @xref{Debug
  295. Options}.
  296. @subsubsection Examples of option use
  297. Here is an example of a session in which some read and debug option
  298. handling procedures are used. In this example, the user
  299. @enumerate
  300. @item
  301. Notices that the symbols @code{abc} and @code{aBc} are not the same
  302. @item
  303. Examines the @code{read-options}, and sees that @code{case-insensitive}
  304. is set to ``no''.
  305. @item
  306. Enables @code{case-insensitive}
  307. @item
  308. Quits the recursive prompt
  309. @item
  310. Verifies that now @code{aBc} and @code{abc} are the same
  311. @end enumerate
  312. @smalllisp
  313. scheme@@(guile-user)> (define abc "hello")
  314. scheme@@(guile-user)> abc
  315. $1 = "hello"
  316. scheme@@(guile-user)> aBc
  317. <unknown-location>: warning: possibly unbound variable `aBc'
  318. ERROR: In procedure module-lookup:
  319. ERROR: Unbound variable: aBc
  320. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
  321. scheme@@(guile-user) [1]> (read-options 'help)
  322. copy no Copy source code expressions.
  323. positions yes Record positions of source code expressions.
  324. case-insensitive no Convert symbols to lower case.
  325. keywords #f Style of keyword recognition: #f, 'prefix or 'postfix.
  326. r6rs-hex-escapes no Use R6RS variable-length character and string hex escapes.
  327. square-brackets yes Treat `[' and `]' as parentheses, for R6RS compatibility.
  328. hungry-eol-escapes no In strings, consume leading whitespace after an
  329. escaped end-of-line.
  330. curly-infix no Support SRFI-105 curly infix expressions.
  331. scheme@@(guile-user) [1]> (read-enable 'case-insensitive)
  332. $2 = (square-brackets keywords #f case-insensitive positions)
  333. scheme@@(guile-user) [1]> ,q
  334. scheme@@(guile-user)> aBc
  335. $3 = "hello"
  336. @end smalllisp
  337. @c Local Variables:
  338. @c TeX-master: "guile.texi"
  339. @c End: