Scheme has the lovely property that its expressions may be represented
as data. The
eval procedure takes a Scheme datum and evaluates
it as code.
Evaluate exp, a list representing a Scheme expression,
in the top-level environment specified by module_or_state.
While exp is evaluated (using
module_or_state is made the current module. The current module
is reset to its previous value when
XXX - dynamic states.
Example: (eval ’(+ 1 2) (interaction-environment))
Return a specifier for the environment that contains implementation–defined bindings, typically a superset of those listed in the report. The intent is that this procedure will return the environment in which the implementation would evaluate expressions dynamically typed by the user.
See Environments, for other environments.
One does not always receive code as Scheme data, of course, and this is
especially the case for Guile’s other language implementations
(see Support for Other Languages). For the case in which all you have is a
string, we have
eval-string. There is a legacy version of this
procedure in the default environment, but you really want the one from
(ice-9 eval-string), so load it up:
(use-modules (ice-9 eval-string))
Parse string according to the current language, normally Scheme. Evaluate or compile the expressions it contains, in order, returning the last expression.
If the module keyword argument is set, save a module excursion (see Module System Reflection) and set the current module to module before evaluation.
The file, line, and column keyword arguments can be used to indicate that the source string begins at a particular source location.
Finally, lang is a language, defaulting to the current language, and the expression is compiled if compile? is true or there is no evaluator for the given language.
These C bindings call
eval-string), evaluating within module or the current module.
(const char *string)¶
scm_eval_string, but taking a C string in locale encoding instead
Call proc with arguments arg … and the elements of the arglst list.
scm_apply takes parameters corresponding to a Scheme level
(lambda (proc arg1 . rest) ...). So arg1 and all but the
last element of the rest list make up arg …, and the
last element of rest is the arglst list. Or if rest
is the empty list
SCM_EOL then there’s no arg …, and
(arg1) is the arglst.
arglst is not modified, but the rest list passed to
scm_apply is modified.
Call proc with the given arguments.
Call proc with any number of arguments. The argument list must be
SCM_UNDEFINED. For example:
scm_call (scm_c_public_ref ("guile", "+"), scm_from_int (1), scm_from_int (2), SCM_UNDEFINED);
Call proc with the array of arguments argv, as a
SCM*. The length of the arguments should be passed in
nargs, as a