scsh-users
[Top] [All Lists]

Re: Global variable not updated by function called in (run (begin ...))

To: scsh@martigny.ai.mit.edu
Subject: Re: Global variable not updated by function called in (run (begin ...))
From: shivers@ai.mit.edu (Olin Shivers)
Date: 03 Sep 1996 18:45:33 -0400
Organization: Artificial Intelligence Lab, MIT
Reply-to: shivers@ai.mit.edu
   From: dmh@tibco.COM (David Hull)
   Newsgroups: comp.lang.scheme.scsh
   Date: 3 Sep 1996 17:47:25 -0400

   % scsh
   Scsh 0.4
   > (define foo 0)
   > (define (inc-foo!)
           (set! foo (+ foo 1))
           (format #t "Foo is ~a\n" foo))
   > foo
   0
   > (inc-foo!)
   Foo is 1
   #f
   > foo
   1
   > (run (begin (inc-foo!)))
   Foo is 2
   0
   > foo
   1

   This is puzzling at best.  Evidently, inside the (run (begin ...))
   form, inc-foo! sees a copy of foo, not the global itself.  Is this
   deliberate?  Is it penance for side-effecting a global variable?

If I set a variable in one scsh process, that doesn't change its value in
another scsh process, right? Even if the two scsh processes are related
by fork(). The RUN operator delimits a process boundary.
        -Olin

<Prev in Thread] Current Thread [Next in Thread>