[R7RS eval]
Evaluate expr under the environment env.
In Gauche, env is just a <module>
object.
R5RS and R7RS provide a portable way to obtain environment.
R5RS way is described below. R7RS way is
described in scheme.eval
- R7RS eval.
[R5RS]
Returns an environment specifier which can be used as the second
argument of eval
. Right now an environment specifier
is just a module. (null-environment 5)
returns
a null
module, which contains just the syntactic bindings
specified in R5RS, (scheme-report-environment 5)
returns a scheme
module, which contains syntactic and procedure
bindings in R5RS, and (interaction-environment)
returns
a user
module that contains all the Gauche built-ins plus
whatever the user defined.
It is possible that the Gauche adopts a first-class environment object
in future, so do not rely on the fact that the environment specifier
is just a module.
An error is signaled if a value other than 5 is passed as version argument.
This exports Gosh
’s default read-eval-print loop to applications.
Each argument can be #f
, which indicates it to use Gauche’s
default procedure(s), or a procedure that satisfies the
following conditions.
A procedure that takes no arguments. It is supposed to read an expression and returns it.
A procedure that takes two arguments, an expression and an environment specifier. It is supposed to evaluate the expression and returns zero or more value(s).
A procedure that takes zero or more arguments. It is supposed to print out these values. The result of this procedure is discarded.
A procedure that takes no arguments. It is supposed to print out the prompt. The result of this procedure is discarded.
Given those procedures, read-eval-print-loop
runs as follows:
read-eval-print-loop
.
When an error is signaled from one of those procedures, it is captured and reported by the default escape handler, then the loop restarts from 1.
It is OK to capture a continuation within those procedures and re-invoke them afterwards.