Commit | Line | Data |
---|---|---|
07d83abe MV |
1 | @c -*-texinfo-*- |
2 | @c This is part of the GNU Guile Reference Manual. | |
c869f0c1 | 3 | @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 |
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 | ||
10 | Why is my Guile different from your Guile? There are three kinds of | |
11 | possible variation: | |
12 | ||
13 | @itemize @bullet | |
14 | @item | |
15 | build differences --- different versions of the Guile source code, | |
16 | installation directories, configuration flags that control pieces of | |
17 | functionality being included or left out, etc. | |
18 | ||
19 | @item | |
20 | differences in dynamically loaded code --- behaviour and features | |
21 | provided by modules that can be dynamically loaded into a running Guile | |
22 | ||
23 | @item | |
24 | different runtime options --- some of the options that are provided for | |
25 | controlling Guile's behaviour may be set differently. | |
26 | @end itemize | |
27 | ||
28 | Guile provides ``introspective'' variables and procedures to query all | |
29 | of these possible variations at runtime. For runtime options, it also | |
30 | provides procedures to change the settings of options and to obtain | |
31 | documentation 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 | ||
43 | The following procedures and variables provide information about how | |
44 | Guile 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 () | |
56 | Return a string describing Guile's full version number, effective | |
57 | version number, major, minor or micro version number, respectively. | |
58 | The @code{effective-version} function returns the version name that | |
59 | should remain unchanged during a stable series. Currently that means | |
60 | that it omits the micro version. The effective version should be used | |
61 | for items like the versioned share directory name | |
679cceed | 62 | i.e.@: @file{/usr/share/guile/1.6/} |
07d83abe MV |
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 () | |
75 | Return the name of the directory under which Guile Scheme files in | |
76 | general 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 () | |
82 | Return the name of the directory where the Guile Scheme files that | |
83 | belong to the core Guile installation (as opposed to files from a 3rd | |
45867c2a | 84 | party package) are installed. On Unix-like systems this is usually |
1a1ce64d RW |
85 | @file{/usr/local/share/guile/@var{GUILE_EFFECTIVE_VERSION}} or |
86 | @file{/usr/share/guile/@var{GUILE_EFFECTIVE_VERSION}}; | |
45867c2a | 87 | |
1a1ce64d RW |
88 | @noindent |
89 | for example @file{/usr/local/share/guile/1.6}. | |
07d83abe MV |
90 | @end deffn |
91 | ||
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}. | |
97 | @end deffn | |
98 | ||
892aea8b | 99 | @cindex @env{GUILE_LOAD_PATH} |
07d83abe MV |
100 | @defvar %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 | |
8370b00b | 103 | @code{(list (%site-dir) (%library-dir) (%package-data-dir))}, |
892aea8b | 104 | prepended with the contents of the @env{GUILE_LOAD_PATH} environment variable, |
07d83abe MV |
105 | if it is set. |
106 | @end defvar | |
107 | ||
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} | |
113 | is returned. | |
114 | @end deffn | |
115 | ||
88cbb421 LC |
116 | @deffn {Scheme Procedure} search-path path filename [extensions [require-exts?]] |
117 | @deffnx {C Function} scm_search_path (path, filename, rest) | |
07d83abe MV |
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} | |
88cbb421 LC |
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}. | |
128 | ||
129 | For compatibility with Guile 1.8 and earlier, the C function takes only | |
130 | three arguments | |
07d83abe MV |
131 | @end deffn |
132 | ||
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. | |
137 | ||
138 | Briefly, here are the keys in @code{%guile-build-info}, by group: | |
139 | ||
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} | |
158 | @table @asis | |
159 | @item directories | |
160 | srcdir, top_srcdir, prefix, exec_prefix, bindir, sbindir, libexecdir, | |
161 | datadir, sysconfdir, sharedstatedir, localstatedir, libdir, infodir, | |
162 | mandir, includedir, pkgdatadir, pkglibdir, pkgincludedir | |
163 | @cindex @code{LIBS} | |
164 | @item env vars | |
165 | LIBS | |
166 | @cindex @code{guileversion} | |
167 | @cindex @code{libguileinterface} | |
168 | @cindex @code{buildstamp} | |
169 | @item versioning info | |
170 | guileversion, libguileinterface, buildstamp | |
171 | @end table | |
172 | ||
173 | Values are all strings. The value for @code{LIBS} is typically found | |
097a793b AW |
174 | also as a part of @code{pkg-config --libs |
175 | guile-@value{EFFECTIVE-VERSION}} output. The value for | |
07d83abe | 176 | @code{guileversion} has form X.Y.Z, and should be the same as returned |
097a793b AW |
177 | by @code{(version)}. The value for @code{libguileinterface} is libtool |
178 | compatible and has form CURRENT:REVISION:AGE (@pxref{Versioning,, | |
179 | Library interface versions, libtool, GNU Libtool}). The value for | |
180 | @code{buildstamp} is the output of the command @samp{date -u +'%Y-%m-%d | |
181 | %T'} (UTC). | |
07d83abe MV |
182 | |
183 | In the source, @code{%guile-build-info} is initialized from | |
184 | libguile/libpath.h, which is completely generated, so deleting this file | |
185 | before a build guarantees up-to-date values for that build. | |
186 | @end defvar | |
187 | ||
d7a22073 LC |
188 | @cindex GNU triplet |
189 | @cindex canonical host type | |
190 | ||
191 | @defvar %host-type | |
192 | The canonical host type (GNU triplet) of the host Guile was configured | |
193 | for, e.g., @code{"x86_64-unknown-linux-gnu"} (@pxref{Canonicalizing,,, | |
194 | autoconf, The GNU Autoconf Manual}). | |
195 | @end defvar | |
07d83abe MV |
196 | |
197 | @node Feature Tracking | |
198 | @subsection Feature Tracking | |
199 | ||
200 | Guile has a Scheme level variable @code{*features*} that keeps track to | |
201 | some extent of the features that are available in a running Guile. | |
202 | @code{*features*} is a list of symbols, for example @code{threads}, each | |
203 | of which describes a feature of the running Guile process. | |
204 | ||
205 | @defvar *features* | |
206 | A list of symbols describing available features of the Guile process. | |
207 | @end defvar | |
208 | ||
209 | You shouldn't modify the @code{*features*} variable directly using | |
210 | @code{set!}. Instead, see the procedures that are provided for this | |
211 | purpose in the following subsection. | |
212 | ||
213 | @menu | |
214 | * Feature Manipulation:: Checking for and advertising features. | |
215 | * Common Feature Symbols:: Commonly available features. | |
216 | @end menu | |
217 | ||
218 | ||
219 | @node Feature Manipulation | |
220 | @subsubsection Feature Manipulation | |
221 | ||
222 | To check whether a particular feature is available, use the | |
223 | @code{provided?} procedure: | |
224 | ||
225 | @deffn {Scheme Procedure} provided? feature | |
226 | @deffnx {Deprecated Scheme Procedure} feature? feature | |
227 | Return @code{#t} if the specified @var{feature} is available, otherwise | |
228 | @code{#f}. | |
229 | @end deffn | |
230 | ||
231 | To advertise a feature from your own Scheme code, you can use the | |
232 | @code{provide} procedure: | |
233 | ||
234 | @deffn {Scheme Procedure} provide feature | |
235 | Add @var{feature} to the list of available features in this Guile | |
236 | process. | |
237 | @end deffn | |
238 | ||
239 | For C code, the equivalent function takes its feature name as a | |
240 | @code{char *} argument for convenience: | |
241 | ||
242 | @deftypefn {C Function} void scm_add_feature (const char *str) | |
243 | Add a symbol with name @var{str} to the list of available features in | |
244 | this Guile process. | |
245 | @end deftypefn | |
246 | ||
247 | ||
248 | @node Common Feature Symbols | |
249 | @subsubsection Common Feature Symbols | |
250 | ||
251 | In general, a particular feature may be available for one of two | |
252 | reasons. Either because the Guile library was configured and compiled | |
679cceed | 253 | with that feature enabled --- i.e.@: the feature is built into the library |
07d83abe MV |
254 | on your system. Or because some C or Scheme code that was dynamically |
255 | loaded by Guile has added that feature to the list. | |
256 | ||
257 | In the first category, here are the features that the current version of | |
258 | Guile may define (depending on how it is built), and what they mean. | |
259 | ||
260 | @table @code | |
261 | @item array | |
262 | Indicates support for arrays (@pxref{Arrays}). | |
263 | ||
264 | @item array-for-each | |
265 | Indicates availability of @code{array-for-each} and other array mapping | |
40499598 | 266 | procedures (@pxref{Arrays}). |
07d83abe MV |
267 | |
268 | @item char-ready? | |
269 | Indicates that the @code{char-ready?} function is available | |
270 | (@pxref{Reading}). | |
271 | ||
272 | @item complex | |
273 | Indicates support for complex numbers. | |
274 | ||
275 | @item current-time | |
276 | Indicates availability of time-related functions: @code{times}, | |
277 | @code{get-internal-run-time} and so on (@pxref{Time}). | |
278 | ||
279 | @item debug-extensions | |
280 | Indicates that the debugging evaluator is available, together with the | |
281 | options for controlling it. | |
282 | ||
283 | @item delay | |
284 | Indicates support for promises (@pxref{Delayed Evaluation}). | |
285 | ||
286 | @item EIDs | |
287 | Indicates that the @code{geteuid} and @code{getegid} really return | |
288 | effective user and group IDs (@pxref{Processes}). | |
289 | ||
290 | @item inexact | |
291 | Indicates support for inexact numbers. | |
292 | ||
293 | @item i/o-extensions | |
294 | Indicates availability of the following extended I/O procedures: | |
295 | @code{ftell}, @code{redirect-port}, @code{dup->fdes}, @code{dup2}, | |
296 | @code{fileno}, @code{isatty?}, @code{fdopen}, | |
297 | @code{primitive-move->fdes} and @code{fdes->ports} (@pxref{Ports and | |
298 | File Descriptors}). | |
299 | ||
300 | @item net-db | |
301 | Indicates availability of network database functions: | |
302 | @code{scm_gethost}, @code{scm_getnet}, @code{scm_getproto}, | |
303 | @code{scm_getserv}, @code{scm_sethost}, @code{scm_setnet}, @code{scm_setproto}, | |
304 | @code{scm_setserv}, and their `byXXX' variants (@pxref{Network | |
305 | Databases}). | |
306 | ||
307 | @item posix | |
308 | Indicates support for POSIX functions: @code{pipe}, @code{getgroups}, | |
309 | @code{kill}, @code{execl} and so on (@pxref{POSIX}). | |
310 | ||
311 | @item random | |
312 | Indicates availability of random number generation functions: | |
313 | @code{random}, @code{copy-random-state}, @code{random-uniform} and so on | |
314 | (@pxref{Random}). | |
315 | ||
316 | @item reckless | |
317 | Indicates that Guile was built with important checks omitted --- you | |
318 | should never see this! | |
319 | ||
320 | @item regex | |
321 | Indicates support for POSIX regular expressions using | |
322 | @code{make-regexp}, @code{regexp-exec} and friends (@pxref{Regexp | |
323 | Functions}). | |
324 | ||
325 | @item socket | |
326 | Indicates availability of socket-related functions: @code{socket}, | |
327 | @code{bind}, @code{connect} and so on (@pxref{Network Sockets and | |
328 | Communication}). | |
329 | ||
330 | @item sort | |
331 | Indicates availability of sorting and merging functions | |
332 | (@pxref{Sorting}). | |
333 | ||
334 | @item system | |
335 | Indicates that the @code{system} function is available | |
336 | (@pxref{Processes}). | |
337 | ||
338 | @item threads | |
339 | Indicates support for multithreading (@pxref{Threads}). | |
340 | ||
341 | @item values | |
342 | Indicates support for multiple return values using @code{values} and | |
343 | @code{call-with-values} (@pxref{Multiple Values}). | |
344 | @end table | |
345 | ||
346 | Available features in the second category depend, by definition, on what | |
347 | additional code your Guile process has loaded in. The following table | |
348 | lists features that you might encounter for this reason. | |
349 | ||
350 | @table @code | |
351 | @item defmacro | |
352 | Indicates that the @code{defmacro} macro is available (@pxref{Macros}). | |
353 | ||
354 | @item describe | |
355 | Indicates that the @code{(oop goops describe)} module has been loaded, | |
356 | which provides a procedure for describing the contents of GOOPS | |
357 | instances. | |
358 | ||
359 | @item readline | |
360 | Indicates that Guile has loaded in Readline support, for command line | |
361 | editing (@pxref{Readline Support}). | |
362 | ||
363 | @item record | |
364 | Indicates support for record definition using @code{make-record-type} | |
365 | and friends (@pxref{Records}). | |
366 | @end table | |
367 | ||
368 | Although these tables may seem exhaustive, it is probably unwise in | |
369 | practice to rely on them, as the correspondences between feature symbols | |
370 | and available procedures/behaviour are not strictly defined. If you are | |
371 | writing code that needs to check for the existence of some procedure, it | |
372 | is probably safer to do so directly using the @code{defined?} procedure | |
373 | than to test for the corresponding feature using @code{provided?}. | |
374 | ||
375 | ||
376 | @node Runtime Options | |
377 | @subsection Runtime Options | |
378 | ||
1cfdb1bb AW |
379 | There are a number of runtime options available for paramaterizing |
380 | built-in procedures, like @code{read}, and built-in behavior, like what | |
381 | happens on an uncaught error. | |
07d83abe | 382 | |
1cfdb1bb | 383 | For more information on reader options, @xref{Scheme Read}. |
07d83abe | 384 | |
1cfdb1bb | 385 | For more information on print options, @xref{Scheme Write}. |
07d83abe | 386 | |
659c1e29 AW |
387 | Finally, for more information on debugger options, @xref{Debug |
388 | Options}. | |
07d83abe | 389 | |
07d83abe MV |
390 | @subsubsection Examples of option use |
391 | ||
392 | Here is an example of a session in which some read and debug option | |
393 | handling procedures are used. In this example, the user | |
394 | ||
395 | @enumerate | |
396 | @item | |
397 | Notices that the symbols @code{abc} and @code{aBc} are not the same | |
398 | @item | |
399 | Examines the @code{read-options}, and sees that @code{case-insensitive} | |
400 | is set to ``no''. | |
401 | @item | |
402 | Enables @code{case-insensitive} | |
403 | @item | |
1cfdb1bb | 404 | Quits the recursive prompt |
07d83abe | 405 | @item |
1cfdb1bb | 406 | Verifies that now @code{aBc} and @code{abc} are the same |
07d83abe MV |
407 | @end enumerate |
408 | ||
07d83abe | 409 | @smalllisp |
1cfdb1bb AW |
410 | scheme@@(guile-user)> (define abc "hello") |
411 | scheme@@(guile-user)> abc | |
412 | $1 = "hello" | |
413 | scheme@@(guile-user)> aBc | |
414 | <unknown-location>: warning: possibly unbound variable `aBc' | |
415 | ERROR: In procedure module-lookup: | |
07d83abe | 416 | ERROR: Unbound variable: aBc |
1cfdb1bb AW |
417 | Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. |
418 | scheme@@(guile-user) [1]> (read-options 'help) | |
419 | copy no Copy source code expressions. | |
420 | positions yes Record positions of source code expressions. | |
421 | case-insensitive no Convert symbols to lower case. | |
422 | keywords #f Style of keyword recognition: #f, 'prefix or 'postfix. | |
423 | r6rs-hex-escapes no Use R6RS variable-length character and string hex escapes. | |
424 | square-brackets yes Treat `[' and `]' as parentheses, for R6RS compatibility. | |
c869f0c1 AW |
425 | hungry-eol-escapes no In strings, consume leading whitespace after an |
426 | escaped end-of-line. | |
1cfdb1bb AW |
427 | scheme@@(guile-user) [1]> (read-enable 'case-insensitive) |
428 | $2 = (square-brackets keywords #f case-insensitive positions) | |
429 | scheme@@(guile-user) [1]> ,q | |
430 | scheme@@(guile-user)> aBc | |
431 | $3 = "hello" | |
07d83abe MV |
432 | @end smalllisp |
433 | ||
434 | ||
435 | @c Local Variables: | |
436 | @c TeX-master: "guile.texi" | |
437 | @c End: |