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

Re: [Scheme-reports] loading libraries

On 10/23/2013 6:12 PM, Alex Shinn wrote:
> The libraries may in fact be loaded multiple times,
> to allow for models such as Racket which require
> clean environments for each library expansion in
> order to avoid unwanted macro interactions.

I don't understand how parameters work in implementations where 
libraries can be loaded more than once.

In the following example, each time (bakery size) is loaded, size will 
be bound to a different parameter. An implementation that loads 
libraries each time they are imported would write (small cake). And an 
implementation which loads libraries only once would write (large cake).

(define-library (bakery size)
     (import (scheme base))
     (export size)
         (define size (make-parameter 'small))))

(define-library (bakery cake)
     (import (scheme base))
     (import (bakery size))
     (export make-cake)
         (define (make-cake)
             (list (size) 'cake))))

;; program
(import (scheme base))
(import (scheme write))
(import (bakery size))
(import (bakery cake))

(parameterize ((size 'large)) (write (make-cake)))

Scheme-reports mailing list