remove lambda wrap hack of brainfuck tree-il compiler
[bpt/guile.git] / doc / ref / api-evaluation.texi
CommitLineData
07d83abe
MV
1@c -*-texinfo-*-
2@c This is part of the GNU Guile Reference Manual.
40296bab 3@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006
07d83abe
MV
4@c Free Software Foundation, Inc.
5@c See the file guile.texi for copying conditions.
6
7@page
00ce5125 8@node Read/Load/Eval/Compile
07d83abe
MV
9@section Reading and Evaluating Scheme Code
10
11This chapter describes Guile functions that are concerned with reading,
00ce5125 12loading, evaluating, and compiling Scheme code at run time.
07d83abe
MV
13
14@menu
15* Scheme Syntax:: Standard and extended Scheme syntax.
16* Scheme Read:: Reading Scheme code.
17* Fly Evaluation:: Procedures for on the fly evaluation.
00ce5125 18* Compilation:: How to compile Scheme files and procedures.
07d83abe
MV
19* Loading:: Loading Scheme code from file.
20* Delayed Evaluation:: Postponing evaluation until it is needed.
21* Local Evaluation:: Evaluation in a local environment.
22* Evaluator Behaviour:: Modifying Guile's evaluator.
00ce5125 23* VM Behaviour:: Modifying Guile's virtual machine.
07d83abe
MV
24@end menu
25
26
27@node Scheme Syntax
28@subsection Scheme Syntax: Standard and Guile Extensions
29
30@menu
31* Expression Syntax::
32* Comments::
33* Block Comments::
34* Case Sensitivity::
35* Keyword Syntax::
36* Reader Extensions::
37@end menu
38
39
40@node Expression Syntax
41@subsubsection Expression Syntax
42
43An expression to be evaluated takes one of the following forms.
44
45@table @nicode
46
47@item @var{symbol}
48A symbol is evaluated by dereferencing. A binding of that symbol is
49sought and the value there used. For example,
50
51@example
52(define x 123)
53x @result{} 123
54@end example
55
56@item (@var{proc} @var{args}@dots{})
57A parenthesised expression is a function call. @var{proc} and each
58argument are evaluated, then the function (which @var{proc} evaluated
59to) is called with those arguments.
60
61The order in which @var{proc} and the arguments are evaluated is
62unspecified, so be careful when using expressions with side effects.
63
64@example
65(max 1 2 3) @result{} 3
66
67(define (get-some-proc) min)
68((get-some-proc) 1 2 3) @result{} 1
69@end example
70
71The same sort of parenthesised form is used for a macro invocation,
72but in that case the arguments are not evaluated. See the
73descriptions of macros for more on this (@pxref{Macros}, and
74@pxref{Syntax Rules}).
75
76@item @var{constant}
77Number, string, character and boolean constants evaluate ``to
78themselves'', so can appear as literals.
79
80@example
81123 @result{} 123
8299.9 @result{} 99.9
83"hello" @result{} "hello"
84#\z @result{} #\z
85#t @result{} #t
86@end example
87
88Note that an application must not attempt to modify literal strings,
89since they may be in read-only memory.
90
91@item (quote @var{data})
92@itemx '@var{data}
93@findex quote
94@findex '
95Quoting is used to obtain a literal symbol (instead of a variable
96reference), a literal list (instead of a function call), or a literal
97vector. @nicode{'} is simply a shorthand for a @code{quote} form.
98For example,
99
100@example
101'x @result{} x
102'(1 2 3) @result{} (1 2 3)
103'#(1 (2 3) 4) @result{} #(1 (2 3) 4)
104(quote x) @result{} x
105(quote (1 2 3)) @result{} (1 2 3)
106(quote #(1 (2 3) 4)) @result{} #(1 (2 3) 4)
107@end example
108
109Note that an application must not attempt to modify literal lists or
110vectors obtained from a @code{quote} form, since they may be in
111read-only memory.
112
113@item (quasiquote @var{data})
114@itemx `@var{data}
115@findex quasiquote
116@findex `
117Backquote quasi-quotation is like @code{quote}, but selected
118sub-expressions are evaluated. This is a convenient way to construct
119a list or vector structure most of which is constant, but at certain
120points should have expressions substituted.
121
122The same effect can always be had with suitable @code{list},
123@code{cons} or @code{vector} calls, but quasi-quoting is often easier.
124
125@table @nicode
126
127@item (unquote @var{expr})
128@itemx ,@var{expr}
129@findex unquote
130@findex ,
131Within the quasiquote @var{data}, @code{unquote} or @code{,} indicates
132an expression to be evaluated and inserted. The comma syntax @code{,}
133is simply a shorthand for an @code{unquote} form. For example,
134
135@example
136`(1 2 ,(* 9 9) 3 4) @result{} (1 2 81 3 4)
137`(1 (unquote (+ 1 1)) 3) @result{} (1 2 3)
138`#(1 ,(/ 12 2)) @result{} #(1 6)
139@end example
140
141@item (unquote-splicing @var{expr})
142@itemx ,@@@var{expr}
143@findex unquote-splicing
144@findex ,@@
145Within the quasiquote @var{data}, @code{unquote-splicing} or
146@code{,@@} indicates an expression to be evaluated and the elements of
147the returned list inserted. @var{expr} must evaluate to a list. The
148``comma-at'' syntax @code{,@@} is simply a shorthand for an
149@code{unquote-splicing} form.
150
151@example
152(define x '(2 3))
153`(1 ,@@x 4) @result{} (1 2 3 4)
154`(1 (unquote-splicing (map 1+ x))) @result{} (1 3 4)
155`#(9 ,@@x 9) @result{} #(9 2 3 9)
156@end example
157
158Notice @code{,@@} differs from plain @code{,} in the way one level of
159nesting is stripped. For @code{,@@} the elements of a returned list
160are inserted, whereas with @code{,} it would be the list itself
161inserted.
162@end table
163
164@c
165@c FIXME: What can we say about the mutability of a quasiquote
166@c result? R5RS doesn't seem to specify anything, though where it
167@c says backquote without commas is the same as plain quote then
168@c presumably the "fixed" portions of a quasiquote expression must be
169@c treated as immutable.
170@c
171
172@end table
173
174
175@node Comments
176@subsubsection Comments
177
178@c FIXME::martin: Review me!
179
180Comments in Scheme source files are written by starting them with a
181semicolon character (@code{;}). The comment then reaches up to the end
182of the line. Comments can begin at any column, and the may be inserted
183on the same line as Scheme code.
184
185@lisp
186; Comment
187;; Comment too
188(define x 1) ; Comment after expression
189(let ((y 1))
190 ;; Display something.
191 (display y)
192;;; Comment at left margin.
193 (display (+ y 1)))
194@end lisp
195
196It is common to use a single semicolon for comments following
197expressions on a line, to use two semicolons for comments which are
198indented like code, and three semicolons for comments which start at
199column 0, even if they are inside an indented code block. This
200convention is used when indenting code in Emacs' Scheme mode.
201
202
203@node Block Comments
204@subsubsection Block Comments
456f797b
KR
205@cindex multiline comments
206@cindex block comments
207@cindex #!
208@cindex !#
07d83abe
MV
209
210@c FIXME::martin: Review me!
211
07d83abe
MV
212In addition to the standard line comments defined by R5RS, Guile has
213another comment type for multiline comments, called @dfn{block
214comments}. This type of comment begins with the character sequence
215@code{#!} and ends with the characters @code{!#}, which must appear on a
216line of their own. These comments are compatible with the block
217comments in the Scheme Shell @file{scsh} (@pxref{The Scheme shell
218(scsh)}). The characters @code{#!} were chosen because they are the
219magic characters used in shell scripts for indicating that the name of
220the program for executing the script follows on the same line.
221
222Thus a Guile script often starts like this.
223
224@lisp
225#! /usr/local/bin/guile -s
226!#
227@end lisp
228
229More details on Guile scripting can be found in the scripting section
230(@pxref{Guile Scripting}).
231
232
233@node Case Sensitivity
234@subsubsection Case Sensitivity
235
236@c FIXME::martin: Review me!
237
238Scheme as defined in R5RS is not case sensitive when reading symbols.
239Guile, on the contrary is case sensitive by default, so the identifiers
240
241@lisp
242guile-whuzzy
243Guile-Whuzzy
244@end lisp
245
246are the same in R5RS Scheme, but are different in Guile.
247
248It is possible to turn off case sensitivity in Guile by setting the
249reader option @code{case-insensitive}. More on reader options can be
250found at (@pxref{Reader options}).
251
252@lisp
253(read-enable 'case-insensitive)
254@end lisp
255
256Note that this is seldom a problem, because Scheme programmers tend not
257to use uppercase letters in their identifiers anyway.
258
259
260@node Keyword Syntax
261@subsubsection Keyword Syntax
262
263
264@node Reader Extensions
265@subsubsection Reader Extensions
266
267@deffn {Scheme Procedure} read-hash-extend chr proc
268@deffnx {C Function} scm_read_hash_extend (chr, proc)
269Install the procedure @var{proc} for reading expressions
270starting with the character sequence @code{#} and @var{chr}.
271@var{proc} will be called with two arguments: the character
272@var{chr} and the port to read further data from. The object
273returned will be the return value of @code{read}.
274@end deffn
275
276
277@node Scheme Read
278@subsection Reading Scheme Code
279
280@rnindex read
281@deffn {Scheme Procedure} read [port]
282@deffnx {C Function} scm_read (port)
283Read an s-expression from the input port @var{port}, or from
284the current input port if @var{port} is not specified.
285Any whitespace before the next token is discarded.
286@end deffn
287
288The behaviour of Guile's Scheme reader can be modified by manipulating
289its read options. For more information about options, @xref{User level
290options interfaces}. If you want to know which reader options are
291available, @xref{Reader options}.
292
293@c FIXME::martin: This is taken from libguile/options.c. Is there
294@c actually a difference between 'help and 'full?
295
296@deffn {Scheme Procedure} read-options [setting]
297Display the current settings of the read options. If @var{setting} is
298omitted, only a short form of the current read options is printed.
299Otherwise, @var{setting} should be one of the following symbols:
300@table @code
301@item help
302Display the complete option settings.
303@item full
304Like @code{help}, but also print programmer options.
305@end table
306@end deffn
307
308@deffn {Scheme Procedure} read-enable option-name
309@deffnx {Scheme Procedure} read-disable option-name
310@deffnx {Scheme Procedure} read-set! option-name value
311Modify the read options. @code{read-enable} should be used with boolean
312options and switches them on, @code{read-disable} switches them off.
313@code{read-set!} can be used to set an option to a specific value.
314@end deffn
315
316@deffn {Scheme Procedure} read-options-interface [setting]
317@deffnx {C Function} scm_read_options (setting)
318Option interface for the read options. Instead of using
319this procedure directly, use the procedures @code{read-enable},
320@code{read-disable}, @code{read-set!} and @code{read-options}.
321@end deffn
322
323
324@node Fly Evaluation
325@subsection Procedures for On the Fly Evaluation
326
327@xref{Environments}.
328
329@rnindex eval
330@c ARGFIXME environment/environment specifier
b4fddbbe
MV
331@deffn {Scheme Procedure} eval exp module_or_state
332@deffnx {C Function} scm_eval (exp, module_or_state)
07d83abe
MV
333Evaluate @var{exp}, a list representing a Scheme expression,
334in the top-level environment specified by @var{module}.
335While @var{exp} is evaluated (using @code{primitive-eval}),
336@var{module} is made the current module. The current module
337is reset to its previous value when @var{eval} returns.
b4fddbbe
MV
338XXX - dynamic states.
339Example: (eval '(+ 1 2) (interaction-environment))
07d83abe
MV
340@end deffn
341
342@rnindex interaction-environment
343@deffn {Scheme Procedure} interaction-environment
344@deffnx {C Function} scm_interaction_environment ()
345Return a specifier for the environment that contains
346implementation--defined bindings, typically a superset of those
347listed in the report. The intent is that this procedure will
348return the environment in which the implementation would
349evaluate expressions dynamically typed by the user.
350@end deffn
351
352@deffn {Scheme Procedure} eval-string string [module]
353@deffnx {C Function} scm_eval_string (string)
354@deffnx {C Function} scm_eval_string_in_module (string, module)
355Evaluate @var{string} as the text representation of a Scheme form or
356forms, and return whatever value they produce. Evaluation takes place
357in the given module, or in the current module when no module is given.
358While the code is evaluated, the given module is made the current one.
359The current module is restored when this procedure returns.
360@end deffn
361
40296bab
KR
362@deftypefn {C Function} SCM scm_c_eval_string (const char *string)
363@code{scm_eval_string}, but taking a C string instead of an
364@code{SCM}.
365@end deftypefn
366
07d83abe
MV
367@deffn {Scheme Procedure} apply proc arg1 @dots{} argN arglst
368@deffnx {C Function} scm_apply_0 (proc, arglst)
369@deffnx {C Function} scm_apply_1 (proc, arg1, arglst)
370@deffnx {C Function} scm_apply_2 (proc, arg1, arg2, arglst)
371@deffnx {C Function} scm_apply_3 (proc, arg1, arg2, arg3, arglst)
372@deffnx {C Function} scm_apply (proc, arg, rest)
373@rnindex apply
374Call @var{proc} with arguments @var{arg1} @dots{} @var{argN} plus the
375elements of the @var{arglst} list.
376
377@code{scm_apply} takes parameters corresponding to a Scheme level
378@code{(lambda (proc arg . rest) ...)}. So @var{arg} and all but the
379last element of the @var{rest} list make up
380@var{arg1}@dots{}@var{argN} and the last element of @var{rest} is the
381@var{arglst} list. Or if @var{rest} is the empty list @code{SCM_EOL}
382then there's no @var{arg1}@dots{}@var{argN} and @var{arg} is the
383@var{arglst}.
384
385@var{arglst} is not modified, but the @var{rest} list passed to
386@code{scm_apply} is modified.
387@end deffn
388
389@deffn {C Function} scm_call_0 (proc)
390@deffnx {C Function} scm_call_1 (proc, arg1)
391@deffnx {C Function} scm_call_2 (proc, arg1, arg2)
392@deffnx {C Function} scm_call_3 (proc, arg1, arg2, arg3)
8d596b11 393@deffnx {C Function} scm_call_4 (proc, arg1, arg2, arg3, arg4)
07d83abe
MV
394Call @var{proc} with the given arguments.
395@end deffn
396
397@deffn {Scheme Procedure} apply:nconc2last lst
398@deffnx {C Function} scm_nconc2last (lst)
399@var{lst} should be a list (@var{arg1} @dots{} @var{argN}
400@var{arglst}), with @var{arglst} being a list. This function returns
401a list comprising @var{arg1} to @var{argN} plus the elements of
402@var{arglst}. @var{lst} is modified to form the return. @var{arglst}
403is not modified, though the return does share structure with it.
404
405This operation collects up the arguments from a list which is
406@code{apply} style parameters.
407@end deffn
408
409@deffn {Scheme Procedure} primitive-eval exp
410@deffnx {C Function} scm_primitive_eval (exp)
411Evaluate @var{exp} in the top-level environment specified by
412the current module.
413@end deffn
414
415
00ce5125
AW
416@node Compilation
417@subsection Compiling Scheme Code
418
419The @code{eval} procedure directly interprets the S-expression
420representation of Scheme. An alternate strategy for evaluation is to
421determine ahead of time what computations will be necessary to
422evaluate the expression, and then use that recipe to produce the
423desired results. This is known as @dfn{compilation}.
424
425While it is possible to compile simple Scheme expressions such as
426@code{(+ 2 2)} or even @code{"Hello world!"}, compilation is most
ca445ba5 427interesting in the context of procedures. Compiling a lambda expression
00ce5125
AW
428produces a compiled procedure, which is just like a normal procedure
429except typically much faster, because it can bypass the generic
430interpreter.
431
432Functions from system modules in a Guile installation are normally
433compiled already, so they load and run quickly.
434
435Note that well-written Scheme programs will not typically call the
436procedures in this section, for the same reason that it is often bad
437taste to use @code{eval}. The normal interface to the compiler is the
438command-line file compiler, which can be invoked from the shell as
439@code{guile-tools compile @var{foo.scm}}. This interface needs more
440documentation.
441
442(Why are calls to @code{eval} and @code{compile} usually in bad taste?
443Because they are limited, in that they can only really make sense for
444top-level expressions. Also, most needs for ``compile-time''
445computation are fulfilled by macros and closures. Of course one good
446counterexample is the REPL itself, or any code that reads expressions
447from a port.)
448
ca445ba5
AW
449For more information on the compiler itself, see @ref{Compiling to the
450Virtual Machine}. For information on the virtual machine, see @ref{A
00ce5125
AW
451Virtual Machine for Guile}.
452
453@deffn {Scheme Procedure} compile exp [env=#f] [from=(current-language)] [to=value] [opts=()]
454Compile the expression @var{exp} in the environment @var{env}. If
455@var{exp} is a procedure, the result will be a compiled procedure;
456otherwise @code{compile} is mostly equivalent to @code{eval}.
457
458For a discussion of languages and compiler options, @xref{Compiling to
459the Virtual Machine}.
460@end deffn
461
462@deffn {Scheme Procedure} compile-file file [to=objcode] [opts='()]
463Compile the file named @var{file}.
464
465Output will be written to a file in the current directory whose name
466is computed as @code{(compiled-file-name @var{file})}.
467@end deffn
468
469@deffn {Scheme Procedure} compiled-file-name file
470Compute an appropriate name for a compiled version of a Scheme file
471named @var{file}.
472
473Usually, the result will be the original file name with the
474@code{.scm} suffix replaced with @code{.go}, but the exact behavior
475depends on the contents of the @code{%load-extensions} and
476@code{%load-compiled-extensions} lists.
477@end deffn
478
07d83abe
MV
479@node Loading
480@subsection Loading Scheme Code from File
481
482@rnindex load
ec3a8ace 483@deffn {Scheme Procedure} load filename [reader]
07d83abe 484Load @var{filename} and evaluate its contents in the top-level
ec3a8ace
NJ
485environment. The load paths are not searched.
486
487@var{reader} if provided should be either @code{#f}, or a procedure with
488the signature @code{(lambda (port) @dots{})} which reads the next
489expression from @var{port}. If @var{reader} is @code{#f} or absent,
490Guile's built-in @code{read} procedure is used (@pxref{Scheme Read}).
491
492The @var{reader} argument takes effect by setting the value of the
493@code{current-reader} fluid (see below) before loading the file, and
494restoring its previous value when loading is complete. The Scheme code
495inside @var{filename} can itself change the current reader procedure on
496the fly by setting @code{current-reader} fluid.
497
498If the variable @code{%load-hook} is defined, it should be bound to a
499procedure that will be called before any code is loaded. See
500documentation for @code{%load-hook} later in this section.
07d83abe
MV
501@end deffn
502
00ce5125
AW
503@deffn {Scheme Procedure} load-compiled filename
504Load the compiled file named @var{filename}. The load paths are not
505searched.
506
507Compiling a source file (@pxref{Read/Load/Eval/Compile}) and then
508calling @code{load-compiled} on the resulting file is equivalent to
509calling @code{load} on the source file.
510@end deffn
511
07d83abe
MV
512@deffn {Scheme Procedure} load-from-path filename
513Similar to @code{load}, but searches for @var{filename} in the load
00ce5125
AW
514paths. Preferentially loads a compiled version of the file, if it is
515available and up-to-date.
07d83abe
MV
516@end deffn
517
518@deffn {Scheme Procedure} primitive-load filename
519@deffnx {C Function} scm_primitive_load (filename)
520Load the file named @var{filename} and evaluate its contents in
521the top-level environment. The load paths are not searched;
522@var{filename} must either be a full pathname or be a pathname
523relative to the current directory. If the variable
524@code{%load-hook} is defined, it should be bound to a procedure
525that will be called before any code is loaded. See the
526documentation for @code{%load-hook} later in this section.
527@end deffn
528
40296bab
KR
529@deftypefn {C Function} SCM scm_c_primitive_load (const char *filename)
530@code{scm_primitive_load}, but taking a C string instead of an
531@code{SCM}.
532@end deftypefn
533
07d83abe
MV
534@deffn {Scheme Procedure} primitive-load-path filename
535@deffnx {C Function} scm_primitive_load_path (filename)
5c132e68 536Search @code{%load-path} for the file named @var{filename} and
07d83abe
MV
537load it into the top-level environment. If @var{filename} is a
538relative pathname and is not found in the list of search paths,
00ce5125
AW
539an error is signalled. Preferentially loads a compiled version of the
540file, if it is available and up-to-date.
07d83abe
MV
541@end deffn
542
543@deffn {Scheme Procedure} %search-load-path filename
544@deffnx {C Function} scm_sys_search_load_path (filename)
5c132e68 545Search @code{%load-path} for the file named @var{filename},
07d83abe
MV
546which must be readable by the current user. If @var{filename}
547is found in the list of paths to search or is an absolute
548pathname, return its full pathname. Otherwise, return
549@code{#f}. Filenames may have any of the optional extensions
550in the @code{%load-extensions} list; @code{%search-load-path}
551will try each extension automatically.
552@end deffn
553
ec3a8ace
NJ
554@defvar current-reader
555@code{current-reader} holds the read procedure that is currently being
556used by the above loading procedures to read expressions (from the file
557that they are loading). @code{current-reader} is a fluid, so it has an
558independent value in each dynamic root and should be read and set using
559@code{fluid-ref} and @code{fluid-set!} (@pxref{Fluids and Dynamic
560States}).
561@end defvar
562
07d83abe 563@defvar %load-hook
42ad91f7
KR
564A procedure to be called @code{(%load-hook @var{filename})} whenever a
565file is loaded, or @code{#f} for no such call. @code{%load-hook} is
566used by all of the above loading functions (@code{load},
567@code{load-path}, @code{primitive-load} and
568@code{primitive-load-path}).
569
570For example an application can set this to show what's loaded,
07d83abe
MV
571
572@example
42ad91f7
KR
573(set! %load-hook (lambda (filename)
574 (format #t "Loading ~a ...\n" filename)))
07d83abe 575(load-from-path "foo.scm")
42ad91f7 576@print{} Loading /usr/local/share/guile/site/foo.scm ...
07d83abe 577@end example
07d83abe
MV
578@end defvar
579
580@deffn {Scheme Procedure} current-load-port
581@deffnx {C Function} scm_current_load_port ()
582Return the current-load-port.
583The load port is used internally by @code{primitive-load}.
584@end deffn
585
586@defvar %load-extensions
587A list of default file extensions for files containing Scheme code.
588@code{%search-load-path} tries each of these extensions when looking for
589a file to load. By default, @code{%load-extensions} is bound to the
590list @code{("" ".scm")}.
591@end defvar
592
593
594@node Delayed Evaluation
595@subsection Delayed Evaluation
596@cindex delayed evaluation
597@cindex promises
598
599Promises are a convenient way to defer a calculation until its result
600is actually needed, and to run such a calculation only once.
601
602@deffn syntax delay expr
603@rnindex delay
604Return a promise object which holds the given @var{expr} expression,
605ready to be evaluated by a later @code{force}.
606@end deffn
607
608@deffn {Scheme Procedure} promise? obj
609@deffnx {C Function} scm_promise_p (obj)
610Return true if @var{obj} is a promise.
611@end deffn
612
613@rnindex force
614@deffn {Scheme Procedure} force p
615@deffnx {C Function} scm_force (p)
616Return the value obtained from evaluating the @var{expr} in the given
617promise @var{p}. If @var{p} has previously been forced then its
618@var{expr} is not evaluated again, instead the value obtained at that
619time is simply returned.
620
621During a @code{force}, an @var{expr} can call @code{force} again on
622its own promise, resulting in a recursive evaluation of that
623@var{expr}. The first evaluation to return gives the value for the
624promise. Higher evaluations run to completion in the normal way, but
625their results are ignored, @code{force} always returns the first
626value.
627@end deffn
628
629
630@node Local Evaluation
631@subsection Local Evaluation
632
633[the-environment]
634
635@deffn {Scheme Procedure} local-eval exp [env]
636@deffnx {C Function} scm_local_eval (exp, env)
637Evaluate @var{exp} in its environment. If @var{env} is supplied,
638it is the environment in which to evaluate @var{exp}. Otherwise,
639@var{exp} must be a memoized code object (in which case, its environment
640is implicit).
641@end deffn
642
643
644@node Evaluator Behaviour
645@subsection Evaluator Behaviour
646
647@c FIXME::martin: Maybe this node name is bad, but the old name clashed with
648@c `Evaluator options' under `Options and Config'.
649
650The behaviour of Guile's evaluator can be modified by manipulating the
651evaluator options. For more information about options, @xref{User level
652options interfaces}. If you want to know which evaluator options are
653available, @xref{Evaluator options}.
654
655@c FIXME::martin: This is taken from libguile/options.c. Is there
656@c actually a difference between 'help and 'full?
657
658@deffn {Scheme Procedure} eval-options [setting]
659Display the current settings of the evaluator options. If @var{setting}
660is omitted, only a short form of the current evaluator options is
661printed. Otherwise, @var{setting} should be one of the following
662symbols:
663@table @code
664@item help
665Display the complete option settings.
666@item full
667Like @code{help}, but also print programmer options.
668@end table
669@end deffn
670
671@deffn {Scheme Procedure} eval-enable option-name
672@deffnx {Scheme Procedure} eval-disable option-name
673@deffnx {Scheme Procedure} eval-set! option-name value
674Modify the evaluator options. @code{eval-enable} should be used with boolean
675options and switches them on, @code{eval-disable} switches them off.
676@code{eval-set!} can be used to set an option to a specific value.
677@end deffn
678
679@deffn {Scheme Procedure} eval-options-interface [setting]
680@deffnx {C Function} scm_eval_options_interface (setting)
681Option interface for the evaluation options. Instead of using
682this procedure directly, use the procedures @code{eval-enable},
683@code{eval-disable}, @code{eval-set!} and @code{eval-options}.
684@end deffn
685
686@c FIXME::martin: Why aren't these procedure named like the other options
687@c procedures?
688
689@deffn {Scheme Procedure} traps [setting]
690Display the current settings of the evaluator traps options. If
691@var{setting} is omitted, only a short form of the current evaluator
692traps options is printed. Otherwise, @var{setting} should be one of the
693following symbols:
694@table @code
695@item help
696Display the complete option settings.
697@item full
698Like @code{help}, but also print programmer options.
699@end table
700@end deffn
701
702@deffn {Scheme Procedure} trap-enable option-name
703@deffnx {Scheme Procedure} trap-disable option-name
704@deffnx {Scheme Procedure} trap-set! option-name value
705Modify the evaluator options. @code{trap-enable} should be used with boolean
706options and switches them on, @code{trap-disable} switches them off.
707@code{trap-set!} can be used to set an option to a specific value.
19ab431e
HWN
708
709See @ref{Evaluator trap options} for more information on the available
710trap handlers.
07d83abe
MV
711@end deffn
712
713@deffn {Scheme Procedure} evaluator-traps-interface [setting]
714@deffnx {C Function} scm_evaluator_traps (setting)
715Option interface for the evaluator trap options.
716@end deffn
717
00ce5125
AW
718@node VM Behaviour
719@subsection VM Behaviour
720
721Like the procedures from the previous section that operate on the
722evaluator, there are also procedures to modify the behavior of a
723virtual machine.
724
725The most useful thing that a user can do is to add to one of the
726virtual machine's predefined hooks:
727
728@deffn {Scheme Procedure} vm-next-hook vm
729@deffnx {Scheme Procedure} vm-apply-hook vm
730@deffnx {Scheme Procedure} vm-boot-hook vm
731@deffnx {Scheme Procedure} vm-return-hook vm
732@deffnx {Scheme Procedure} vm-break-hook vm
733@deffnx {Scheme Procedure} vm-exit-hook vm
734@deffnx {Scheme Procedure} vm-halt-hook vm
735@deffnx {Scheme Procedure} vm-enter-hook vm
736Accessors to a virtual machine's hooks. Usually you pass
737@code{(the-vm)} as the @var{vm}.
738@end deffn
739
740@xref{A Virtual Machine for Guile}, for more information on Guile's
741virtual machine.
07d83abe
MV
742
743@c Local Variables:
744@c TeX-master: "guile.texi"
745@c End: