[R6RS] libraries

Manuel Serrano Manuel.Serrano
Tue Dec 13 09:32:14 EST 2005


Mike writes:
> dyb at cs.indiana.edu writes:
> 
> >> I was personally thinking (implicitly, I now realize) that
> >> "immutability" referred to the fact that the SET! on a top-level
> >> variable defined in a module has to be in the body of that same
> >> module.
> >
> > Okay, so the variables aren't actually immutable at all...their values
> > can change over time, but the the agent of change has to be code in the
> > exporting module's body.  In particular,
> >
> >   (library S "scheme://r6rs"
> >     (export P!)
> >     (define s '())
> >     (define (P! y) (set! s (cons y s))))
> >   (library T "scheme://r6rs"
> >     (import S)
> >     (export P0!)
> >     (define (P0!) (P! 0)))
> >
> > is acceptable, right?  What about:
> >
> >   (library S "scheme://r6rs"
> >     (export P!)
> >     (define s '())
> >     (define-syntax P!
> >       (syntax-rules ()
> >         [(_ y) (set! s (cons y s))]))
> >   (library T "scheme://r6rs"
> >     (import S)
> >     (export P0!)
> >     (define (P0!) (P! 0)))
> >
> > The set! to s appears in the body of S, so by a literal reading of your
> > response, it should be okay.
> 
> Yes, this should also be acceptable.
No, that's not to me. This tights together the library system and the
expansion mechanism far too much. Such a design prevents a compiler supporting
old-lisp macros to do a decent job. Unless we change the export clauses
in order to enable constants exports, enabling variables to be mutated 
outside the library that defines them (in macro-expansed code or in direct
code) is inacceptable to me.

-- 
Manuel


More information about the R6RS mailing list