[R6RS] Modules, a second question
Manuel Serrano
Manuel.Serrano
Thu Sep 30 08:39:06 EDT 2004
> (module foo r6rs
> (display (foo 3))
> (define (foo x) x))
>
> Because the first definition of this module must signal an error,
> Manuel writes:
>
> > If it does I don't see how the compiler will be able to do a good job
> > when compiling function calls...
>
> First, let me say that I don't think it's terribly important for
> a compiler to optimize top-level expressions, which are the only
> ones that are made more difficult to optimize by the left-to-right
> order of evaluation here.
This problem does not concern the top level forms.
Consider:
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
(module foo r6rs
(provides gee)
(if (read)
(foo))
(define (foo)
(let loop ((n 1000000000000000000000000000000000000000000000))
(if (> n 0)
(begin
(bar n)
(loop (- n 1))))))
(define (bar n)
<whatever you want>)
(define (gee)
...(foo)...))
-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
Except if the compiler is particularly clever, the call to "bar" in "foo"
will be poorly compiled. Thus, the "external" call to "gee" will be
inefficient...
--
Manuel
More information about the R6RS
mailing list