Next: , Previous: Scheme Read, Up: Read/Load/Eval

5.13.3 Procedures for On the Fly Evaluation

See Environments.

— Scheme Procedure: eval exp module_or_state
— C Function: scm_eval (exp, module_or_state)

Evaluate exp, a list representing a Scheme expression, in the top-level environment specified by module. While exp is evaluated (using primitive-eval), module is made the current module. The current module is reset to its previous value when eval returns. XXX - dynamic states. Example: (eval '(+ 1 2) (interaction-environment))

— Scheme Procedure: interaction-environment
— C Function: scm_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.

— Scheme Procedure: eval-string string [module]
— C Function: scm_eval_string (string)
— C Function: scm_eval_string_in_module (string, module)

Evaluate string as the text representation of a Scheme form or forms, and return whatever value they produce. Evaluation takes place in the given module, or in the current module when no module is given. While the code is evaluated, the given module is made the current one. The current module is restored when this procedure returns.

— C Function: SCM scm_c_eval_string (const char *string)

scm_eval_string, but taking a C string instead of an SCM.

— Scheme Procedure: apply proc arg1 ... argN arglst
— C Function: scm_apply_0 (proc, arglst)
— C Function: scm_apply_1 (proc, arg1, arglst)
— C Function: scm_apply_2 (proc, arg1, arg2, arglst)
— C Function: scm_apply_3 (proc, arg1, arg2, arg3, arglst)
— C Function: scm_apply (proc, arg, rest)

Call proc with arguments arg1 ... argN plus the elements of the arglst list.

scm_apply takes parameters corresponding to a Scheme level (lambda (proc arg . rest) ...). So arg and all but the last element of the rest list make up arg1...argN and the last element of rest is the arglst list. Or if rest is the empty list SCM_EOL then there's no arg1...argN and arg is the arglst.

arglst is not modified, but the rest list passed to scm_apply is modified.

— C Function: scm_call_0 (proc)
— C Function: scm_call_1 (proc, arg1)
— C Function: scm_call_2 (proc, arg1, arg2)
— C Function: scm_call_3 (proc, arg1, arg2, arg3)
— C Function: scm_call_4 (proc, arg1, arg2, arg3, arg4)

Call proc with the given arguments.

— Scheme Procedure: apply:nconc2last lst
— C Function: scm_nconc2last (lst)

lst should be a list (arg1 ... argN arglst), with arglst being a list. This function returns a list comprising arg1 to argN plus the elements of arglst. lst is modified to form the return. arglst is not modified, though the return does share structure with it.

This operation collects up the arguments from a list which is apply style parameters.

— Scheme Procedure: primitive-eval exp
— C Function: scm_primitive_eval (exp)

Evaluate exp in the top-level environment specified by the current module.