No matching definitions.

tur/r7rs/eval

stdlib/r7rs/eval.tur

(scheme eval), (scheme repl), (scheme load) and the environments of (scheme r5rs): eval over an embedded interpreter.

An on-demand R7RS library (see stdlib/r7rs/time.tur). Importing any of the four splices this file in, and its inline C carries the __tur_autolink__: -lturi marker, so a COMPILED program that imports one links the interpreter (libturi) and a program that does not links nothing new. tur --interpret runs the same Turmeric code here, with the inline C primitives replaced by native twins (src/turi/interpreter_natives.c).

The evaluator is one embedded R7RS environment per process (src/turi/r7rs_embed.c). An environment object names the import sets evaluated code sees. A datum crosses as write text and is read back on the far side, so pairs, vectors and strings are COPIED in both directions; a procedure crosses as a handle -- an evaluated procedure is called through the embedded env, and a program procedure passed in (test 1946's (f + 10)) is called back through r7rs-eval-host-call__. A datum that holds a procedure or a record is the named error the reader reports.

Since: r7rs-lang-plan T4

defn

r7rs-eval-c-eval__

(r7rs-eval-c-eval__ [sets :cstr expr :cstr] :int)

internal: evaluate expr (written) with the import sets sets (written); the result kind (see r7rs_embed.h). The first call sets the embedded evaluator up with the stdlib this program was built against and the host trampoline below.

defn

r7rs-eval-c-load__

(r7rs-eval-c-load__ [sets :cstr path :cstr] :int)

internal: load the file at path.

defn

r7rs-eval-c-apply__

(r7rs-eval-c-apply__ [id :int] :int)

internal: call embedded procedure id with the pushed arguments; the result kind.

defn

r7rs-eval-c-push-datum__

(r7rs-eval-c-push-datum__ [text :cstr] :nil)

internal: one argument.

defn

r7rs-eval-c-push-host__

(r7rs-eval-c-push-host__ [id :int] :nil)
defn

r7rs-eval-c-push-proc__

(r7rs-eval-c-push-proc__ [id :int] :nil)
defn

r7rs-eval-c-result-text__

(r7rs-eval-c-result-text__ :cstr)

internal: the last result's payload (the text is copied: an error message outlives the next call).

defn

r7rs-eval-c-result-id__

(r7rs-eval-c-result-id__ :int)
defn

r7rs-eval-c-frame-count__

(r7rs-eval-c-frame-count__ :int)

internal: the arguments of the host call in progress.

defn

r7rs-eval-c-frame-kind__

(r7rs-eval-c-frame-kind__ [i :int] :int)
defn

r7rs-eval-c-frame-text__

(r7rs-eval-c-frame-text__ [i :int] :cstr)
defn

r7rs-eval-c-frame-id__

(r7rs-eval-c-frame-id__ [i :int] :int)
defn

r7rs-eval-c-answer-datum__

(r7rs-eval-c-answer-datum__ [text :cstr] :nil)

internal: the host call's answer.

defn

r7rs-eval-c-answer-host__

(r7rs-eval-c-answer-host__ [id :int] :nil)
defn

r7rs-eval-c-answer-proc__

(r7rs-eval-c-answer-proc__ [id :int] :nil)
defn

r7rs-eval-c-answer-unspecified__

(r7rs-eval-c-answer-unspecified__ :nil)
defn

r7rs-eval-c-answer-raise__

(r7rs-eval-c-answer-raise__ [condition :cstr] :nil)
defn

r7rs-eval-c-cont-hook__

(r7rs-eval-c-cont-hook__ [which :int] :ptr<void>)

internal: the evaluator's continuation hooks (src/turi/r7rs_embed.h), by number: 0 capture, 1 resumable, 2 restore, 3 resumed. A continuation the program captures inside a call from evaluated code to a program procedure copies the evaluator's frames with the stack; through these the evaluator keeps what the frames need on a re-entry (r7rs-eval-continuation-reentry-across-bridge).

defn

r7rs-eval-index-of__

(r7rs-eval-index-of__ [x l i :int] :int)

internal: the position of x (eq?) in l, or -1.

defn

r7rs-eval-host-id__

(r7rs-eval-host-id__ [f] :int)

internal: the host id of program procedure f, assigned on its first crossing.

defn

r7rs-eval-host-ref__

(r7rs-eval-host-ref__ [id :int] :any)

internal: the program procedure with host id id.

defn

r7rs-eval-wrapper-id__

(r7rs-eval-wrapper-id__ [f l] :int)

internal: the embedded id f wraps, or -1.

defn

r7rs-eval-wrapper-of__

(r7rs-eval-wrapper-of__ [id :int l] :any)

internal: the wrapper made for embedded id.

defn

r7rs-eval-proc__

(r7rs-eval-proc__ [id :int] :any)

internal: a program procedure for embedded procedure id: calling it calls the embedded one. One wrapper per id, so a procedure that crosses twice is eq? to itself.

defn

r7rs-eval-unspecified?__

(r7rs-eval-unspecified?__ [x] :bool)

internal: #t for the unspecified value.

defn

r7rs-eval-import__

(r7rs-eval-import__ [kind :int text :cstr id :int] :any)

internal: the program value a result or an argument of kind kind names. What evaluated code raised ('R') is raised again here; an error of the evaluator's own ('E': an unbound name, a form that does not elaborate) is raised as an error object with its message.

defn

r7rs-eval-result__

(r7rs-eval-result__ [kind :int] :any)

internal: the value of the last eval, load or apply.

defn

r7rs-eval-push__

(r7rs-eval-push__ [x] :nil)

internal: one argument of a call into the embedded env.

defn

r7rs-eval-push-all__

(r7rs-eval-push-all__ [l] :nil)
defn

r7rs-eval-apply__

(r7rs-eval-apply__ [id :int args] :any)

internal: call embedded procedure id on args.

defn

r7rs-eval-frame-args__

(r7rs-eval-frame-args__ [i :int acc] :any)

internal: the host call's arguments, as a list.

defn

r7rs-eval-answer__

(r7rs-eval-answer__ [r] :nil)

internal: hand a program value back as the answer.

defn

r7rs-eval-host-call__

(r7rs-eval-host-call__ [id :int] :int)

internal: evaluated code called program procedure id. The embedded evaluator calls this through its C name. What the procedure raises is caught here and raised again on the embedded side, so no escape unwinds through the evaluator's C frames.

defstruct

R7rsEnvironment

(defstruct R7rsEnvironment :heap [sets :cstr])

an environment specifier: the import sets evaluated code sees, written.

defn

r7rs-environment?__

(r7rs-environment?__ [x] :bool)
defn

r7rs-environment-sets__

(r7rs-environment-sets__ [e :R7rsEnvironment] :cstr)
defn

r7rs-environment

(r7rs-environment [& sets :any] :any)

(environment set ...): an environment with those import sets.

defn

r7rs-report-version__

(r7rs-report-version__ [who :cstr v sets :cstr] :any)

internal: (null-environment 5) and (scheme-report-environment 5) name the fifth report and nothing else.

defn

r7rs-null-environment

(r7rs-null-environment [v] :any)

(null-environment 5): the syntax of R5RS.

defn

r7rs-scheme-report-environment

(r7rs-scheme-report-environment [v] :any)

(scheme-report-environment 5): R5RS.

defn

r7rs-interaction-environment

(r7rs-interaction-environment :any)

the REPL's environment: every library; definitions evaluated in it persist for the rest of the run.

defn

r7rs-eval-sets__

(r7rs-eval-sets__ [who :cstr env] :cstr)

internal: the import sets of an environment argument.

defn

r7rs-eval

(r7rs-eval [x env] :any)

(eval expr-or-def environment): evaluate the datum in the environment. A definition persists in the evaluator for later evals.

defn

r7rs-load

(r7rs-load [path & more :any] :any)

(load filename [environment]): evaluate every form of the file (in the interaction environment when none is given).

Internal definitions
r7rs-eval-cont-hooks__-- internal: the hooks, installed in the prelude's