Hi,

consider the following libraries and program:

(define-library (shared)
  (export make-record record? counter)
  (import (scheme base))
  (begin

    (define-record-type record-type
      (make-record)
      record?)

    (define *counter* 0)

    (define (counter)
      (set! *counter* (+ counter 1))
      *counter*)))

(define-library (lib1)
  (export make-record1 record1? counter1)
  (import (scheme base) (shared))
  (begin
    (define make-record1 make-record)
    (define record1? record?)
    (define counter1 counter)))

(define-library (lib2)
  (export make-record2 record2? counter2)
  (import (scheme base) (shared))
  (begin
    (define make-record2 make-record)
    (define record2? record?)
    (define counter2 counter)))

;;; Program

(import (scheme base) (scheme eval) (lib1) (lib2))
; ...

If I call make-record1 and make-record2 in the main program, do they
construct objects of the same type? That is, do both record1? and record2?
return #t for both objects? Similarly, do counter1 and counter2 share the
same internal counter or not?

I'd say the answer to these questions should be yes. Otherwise, it would be
very hard to use libraries together with record types and shared state
(e.g. shared parameter objects) would be impossible.

However, I don't see where the R7RS standard enforces the behaviour that a
library is loaded (at most) once during the execution of one program
together with its referenced libraries.

A related question is what the result of an expression like

(record1? (eval 'make-record1 (environment (lib1)))

in the above program will be. Does (environment (lib1)) loads lib1 anew or
does it use the already existing bindings due to the import of the library
into the program itself? In the former case, the result of the indented
expression would be #f, in the latter case, it would be #t. I think the
latter behaviour is the correct one for a better eval.

Marc
_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to