| To: | scsh-bugs@martigny.ai.mit.edu |
|---|---|
| Subject: | Global variable not updated by function called in (run (begin ...)) |
| From: | David Hull <dmh@tibco.com> |
| Date: | Tue, 3 Sep 96 14:44:34 PDT |
% 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?
Wait a sec, I just thought of something
> (run (begin
(define foo 123)
(inc-foo!)
(format #t "Foo inside run is ~a\n" foo)))
Foo is 2
Foo inside run is 123
0
> foo
1
Obviously, *something* is getting incremented . . .
--dmh
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: scsh on Windows NT?, Steven L Jenkins |
|---|---|
| Next by Date: | Re: Global variable not updated by function called in (run (begin ...)), Olin Shivers |
| Previous by Thread: | scsh on Windows NT?, Eric Hanchrow |
| Next by Thread: | Re: Global variable not updated by function called in (run (begin ...)), Olin Shivers |
| Indexes: | [Date] [Thread] [Top] [All Lists] |