[plt-scheme] Modifying imports

From: ifconfig nslookup (configurator at gmail.com)
Date: Sun Sep 26 06:58:52 EDT 2004

(module a mzscheme
  (define x 1)
  (define y (make-parameter 2))
  (define z
    (let ([value 3])
      (case-lambda
        [() value]
        [(new-value) (set! value new-value)])))
  (provide x y z))

These are the three different ways:
Using the first way, you cannot set the variable.
Using the second and third way, you use (x) to get the variable and
(z) to set it.
The difference between the second and the third is that the second
would have a different value for every thread, if you use them. I.e.
if you set a value in one thread the other thread will still have the
older value.

ifconfig

On Mon, 27 Sep 2004 11:43:42 +0300, Momchil Velikov <velco at fadata.bg> wrote:
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> $ cat foo.ss
> (module foo mzscheme
>   (define some-var 0)
>   (provide some-var))
> $ cat bar.ss
> (require (prefix foo: "foo.ss"))
> 
> (set! foo:some-var 1)
> $ mzscheme -r bar.ss
> bar.ss:3:6: set!: cannot mutate module-required variable at: some-var
> in: foo:some-var
> 
> Is there any way to modify ``module-required'' variables ?
> 
> ~velco
>


Posted on the users mailing list.