[r6rs-discuss] Problems with EVAL
On Sep 12, 2007, at 9:23 PM, AndrevanTonder wrote:
> A couple of problems with EVAL. First, the easy one: I think this
> text has
> problem:
>
> "environment-specifier must be a library specifier, which can be
> created
> using the environment procedure described below"
>
> Specifically, there is no mention in the description of ENVIRONMENT
> of the term
> "library specifier". Instead, it is stated that ENVIRONMENT
> returns an
> "environment" and I do not understand why this apparently doubly
> redundant
> triple indirection of terms is used instead of of just specifying:
>
> (eval expression environment)
>
> and simply saying that an environment may be created by using
> ENVIRONMENT.
Right. There is no such thing as a "library specifier".
Reminder that (scheme-report-environment 5) and (null-environment 5)
also return environment specifiers.
> Then, the more difficult problem. The arguments of ENVIRONMENT are
> generally
> not known until runtime, so I do not understand how a compiled program
> containing ENVIRONMENT can find the necessary libraries unless one /
> requires/
> that ENVIRONMENT may only have as arguments libraries that are present
> in the <import clause> of the toplevel program or library
> containing the
> use of ENVIRONMENT. Yet this is not mentioned. Am I missing
> something?
"environment" was a syntax in 5.91 (IIRC) and was changed to a procedure
in order to allow it to load extensions at runtime. This allows one to
write a plugin loader where the exact set of possible plugins is not
known
at compile time. I have recently made good use of this facility when I
was benchmarking three implementations of hash tables under ikarus. The
benchmarking script takes a library name as one of its arguments and
evaluates an expression in an environment containing that library.
Under ikarus, "environment" takes care of loading libraries that are not
already loaded. It's a pretty nice facility. An excerpt from the
script
is below.
Aziz,,,
!/usr/bin/env ikarus --r6rs-script
(import (ikarus))
(define (build-expr bench-name table-size iters)
---)
(define (test lib-name bench-name table-size iters)
(eval (build-expr bench-name table-size iters)
(environment
'(except (ikarus) make-hash-table ---)
`(,lib-name))))
(apply
(case-lambda
[(script-name lib-name bench-name table-size iters)
(test (string->symbol lib-name)
(string->symbol bench-name)
(string->number table-size)
(string->number iters))])
(command-line-arguments))
Received on Wed Sep 12 2007 - 22:22:19 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC