[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions, loose ends, misprints, etc.



Andre van Tonder wrote:
- Would it be possible to provide a rationale for the notion of indirect exports

Matthew Flatt wrote:
Indirect exports ensure that that all access and mutations to
unexported bindings are apparent within the module (afer macro
expansion). Consequently, the programmer and the compiler can
potentially prove that certain bindings are always used in a certain
way, such as "this unexported function is never called with the wrong
number of arguments". This potential is particularly important for
optimizing compilers.

I don't understand.  Doesn't lexical scoping do that?
If I do:

(library "foo-counter" "scheme://r6rs"
  (export get-foo incr-foo)
  (define foo 1)
  (define-syntax get-foo
    (syntax-rules ()
      ((get-foo)
       foo)))
  (define-syntax incr-foo
    (syntax-rules ()
      ((incr-foo)
       (set! foo (+ foo 1))))))

[Not sure about the exact syntax for 'exports' - srfi-83.html
is inaccessible right now.]

In the example, get-foo and incr-foo are exported, but foo itself is
not.  The compiler can prove that foo is never modified expect by
using incr-foo.  No indirect-exports declaration seems to be needed.

Or is indirect-exports meant for something different?

Kawa's module system allows get-foo and incr-foo to be exported
without foo, essentially as above.

--
	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/