Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!calgary!cpsc!gintera From: gintera@cpsc.ucalgary.ca (Andrew Ginter) Newsgroups: comp.lang.scheme Subject: Re: Non-local variables Summary: locally scoped variables which span procedures Message-ID: <1990May10.003231.3064@calgary.uucp> Date: 10 May 90 00:32:31 GMT References: <9005081621.AA13048@mtecv2.mty.itesm.mx> <7478@accuvax.nwu.edu> Sender: news@calgary.uucp (Network News Manager) Organization: The University of Calgary Lines: 18 In article <7478@accuvax.nwu.edu>, krulwich@ils.nwu.edu (Bruce Krulwich) writes: > This is an issue that has been discussed before. Basically, the treatment > of internal DEFINE's as local definitions makes it impossible to have > static locally-scoped variables that span across procedures. (Having > static variables for one procedure can be achieved as you showed later in > your message.) It seems to me that the variable "a" below is a locally scoped variable which spans procedures... (define dummy (let ((a 0)) (list (lambda () (set! a (+ 1 a)) a) (lambda () (set! a (- 1 a)) a)))) (define count-up (car dummy)) (define count-down (cadr dummy)) Andrew Ginter, 403-282-2984, gintera@CPSC.UCALGARY.CA, Ginter@UNCAMULT.BITNET