[Scheme-reports] loading libraries Michael Montague (23 Oct 2013 18:34 UTC)
Re: [Scheme-reports] loading libraries John Cowan (23 Oct 2013 22:28 UTC)
Re: [Scheme-reports] loading libraries Alex Shinn (24 Oct 2013 01:13 UTC)
Re: [Scheme-reports] loading libraries Michael Montague (24 Oct 2013 04:33 UTC)
(missing)
Re: [Scheme-reports] loading libraries Michael Montague (24 Oct 2013 16:17 UTC)
Re: [Scheme-reports] loading libraries Alex Shinn (25 Oct 2013 00:44 UTC)

Re: [Scheme-reports] loading libraries Michael Montague 24 Oct 2013 16:16 UTC

When I first implemented support for libraries I thought that it was
required that each time a library was imported it had to be loaded which
seemed weird; obviously, I had not read the specification closely
enough. When I realized why parameters were not working, I went back and
read the specification much more closely, and then fixed my library
support to load libraries only once.

Why is the specification vague about how many times libraries get
loaded? As a user of scheme, it would be much clearer to me to be able
to look at a library and know that it was going to be loaded exactly once.

On 10/24/2013 6:28 AM, Sam Tobin-Hochstadt wrote:
> No implementation, to my knowledge, has ever loaded libraries multiple
> times in the example you gave.  Racket loads modules separately for
> each modules's compilation, because each compilation of a single
> module has its own store, not shared with runtime or any other
> compilation.
>
> This modification of your program shows an aspect of Racket's behavior
> -- it writes `(small cake)`.
>
> #lang racket/load
>
> (module |(bakery size)| racket
>    (provide size)
>    (define size (make-parameter 'small)))
>
> (module |(bakery cake)| racket
>    (require (for-syntax '|(bakery size)|))
>    (provide make-cake)
>    (begin
>      (define-syntax (make-cake stx)
>        #`(quote
>           #,(list (size) 'cake)))))
>
> ;; program
> (require '|(bakery size)|)
> (require '|(bakery cake)|)
>
> (parameterize ((size 'large)) (write (make-cake)))
>
>
> On Thu, Oct 24, 2013 at 12:33 AM, Michael Montague <mikemon@gmail.com> wrote:
>> 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)
>>       (begin
>>           (define size (make-parameter 'small))))
>>
>> (define-library (bakery cake)
>>       (import (scheme base))
>>       (import (bakery size))
>>       (export make-cake)
>>       (begin
>>           (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
>> Scheme-reports@scheme-reports.org
>> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports