[PRL] Racket module question
Matthias Felleisen
matthias at ccs.neu.edu
Wed Jun 29 18:12:45 EDT 2011
Here is what i mean:
#lang racket/load
(module C racket
(provide set-store retrieve-store)
(define b (box 0))
(define (set-store x v) (set-box! b v))
(define (retrieve-store x) (unbox b)))
(module A racket
(require 'C)
(set-store 'x 5))
(module B racket
(require 'C 'A)
(displayln (retrieve-store 'x)))
(require 'B)
On Jun 29, 2011, at 6:08 PM, Mitchell Wand wrote:
>
>
> On Wed, Jun 29, 2011 at 6:06 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> On Jun 29, 2011, at 6:03 PM, Mitchell Wand wrote:
>
> > I've got two different modules (call them A and B) that cooperate by manipulating a shared store. The API for the store is provided by a third module C.
> >
> > I'm guessing that simply requiring C in both A and B isn't going to work, because A and B would be working with different instances of the store.
>
>
> You can't possibly mean something like that:
>
> module A:
>
> (require C)
> (set-store 'x 5)
>
> module B:
>
> (require C)
> (displayln (retrieve-store 'x))
>
>
> Because this works just fine.
>
> Oh, really? In that case I'm ready to rock&roll.
More information about the PRL
mailing list