| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes Guile functions that are concerned with reading, loading and evaluating Scheme code at run time.
28.1 Scheme Syntax: Standard and Guile Extensions Standard and extended Scheme syntax. 28.2 Reading Scheme Code Reading Scheme code. 28.3 Procedures for On the Fly Evaluation Procedures for on the fly evaluation. 28.4 Loading Scheme Code from File Loading Scheme code from file. 28.5 Delayed Evaluation Postponing evaluation until it is needed. 28.6 Local Evaluation Evaluation in a local environment. 28.7 Evaluator Behaviour Modifying Guile's evaluator.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
28.1.1 Expression Syntax 28.1.2 Comments 28.1.3 Block Comments 28.1.4 Case Sensitivity 28.1.5 Keyword Syntax 28.1.6 Reader Extensions
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Comments in Scheme source files are written by starting them with a
semicolon character (;). The comment then reaches up to the end
of the line. Comments can begin at any column, and the may be inserted
on the same line as Scheme code.
; Comment ;; Comment too (define x 1) ; Comment after expression (let ((y 1)) ;; Display something. (display y) ;;; Comment at left margin. (display (+ y 1))) |
It is common to use a single semicolon for comments following expressions on a line, to use two semicolons for comments which are indented like code, and three semicolons for comments which start at column 0, even if they are inside an indented code block. This convention is used when indenting code in Emacs' Scheme mode.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In addition to the standard line comments defined by R5RS, Guile has
another comment type for multiline comments, called block
comments. This type of comment begins with the character sequence
#! and ends with the characters !#, which must appear on a
line of their own. These comments are compatible with the block
comments in the Scheme Shell `scsh' (see section 46. The Scheme shell (scsh)). The characters #! were chosen because they are the
magic characters used in shell scripts for indicating that the name of
the program for executing the script follows on the same line.
Thus a Guile script often starts like this.
#! /usr/local/bin/guile -s !# |
More details on Guile scripting can be found in the scripting section (see section 9. Guile Scripting).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Scheme as defined in R5RS is not case sensitive when reading symbols. Guile, on the contrary is case sensitive by default, so the identifiers
guile-whuzzy Guile-Whuzzy |
are the same in R5RS Scheme, but are different in Guile.
It is possible to turn off case sensitivity in Guile by setting the
reader option case-insensitive. More on reader options can be
found at (see section 33.2 Reader options).
(read-enable 'case-insensitive) |
Note that this is seldom a problem, because Scheme programmers tend not to use uppercase letters in their identifiers anyway.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
# and chr.
proc will be called with two arguments: the character
chr and the port to read further data from. The object
returned will be the return value of read.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The behaviour of Guile's Scheme reader can be modified by manipulating its read options. For more information about options, See section 33.1 General option interface. If you want to know which reader options are available, See section 33.2 Reader options.
help
full
help, but also print programmer options.
read-enable should be used with boolean
options and switches them on, read-disable switches them off.
read-set! can be used to set an option to a specific value.
read-enable,
read-disable, read-set! and read-options.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
See section 31.2 Environments.
primitive-eval),
module is made the current module. The current module
is reset to its previous value when eval returns.
interaction-environment.
apply:nconc2last
destroys its argument, so use with care.
(append (list arg1
...) args) as the actual arguments.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
%load-hook is defined, it should be bound to a procedure that
will be called before any code is loaded. See documentation for
%load-hook later in this section.
load, but searches for filename in the load
paths.
%load-hook is defined, it should be bound to a procedure
that will be called before any code is loaded. See the
documentation for %load-hook later in this section.
#f. Filenames may have any of the optional extensions
in the %load-extensions list; %search-load-path
will try each extension automatically.
primitive-load is called. If this
procedure is defined, it will be called with the filename argument that
was passed to primitive-load.
(define %load-hook (lambda (file)
(display "Loading ")
(display file)
(write-line "...."))) => undefined
(load-from-path "foo.scm")
-| Loading /usr/local/share/guile/site/foo.scm....
|
primitive-load.
%search-load-path tries each of these extensions when looking for
a file to load. By default, %load-extensions is bound to the
list ("" ".scm").
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[delay]
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[the-environment]
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The behaviour of Guile's evaluator can be modified by manipulating the evaluator options. For more information about options, See section 33.1 General option interface. If you want to know which evaluator options are available, See section 33.4 Evaluator options.
help
full
help, but also print programmer options.
eval-enable should be used with boolean
options and switches them on, eval-disable switches them off.
eval-set! can be used to set an option to a specific value.
eval-enable,
eval-disable, eval-set! and eval-options.
help
full
help, but also print programmer options.
trap-enable should be used with boolean
options and switches them on, trap-disable switches them off.
trap-set! can be used to set an option to a specific value.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |