[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What's so cool about Scheme?
[Guy Steele - Sun Microsystems Labs <Guy.Steele@Sun.COM>]
>
> What about this?
>
> (define get-balance #f)
> (define deposit #f)
>
> (let ((balance 0))
> (set! get-balance
> (lambda ()
> balance))
> (set! deposit
> (lambda (amount)
> (set! balance (+ balance amount))
> balance)))
>
> That's two closures that share some state ("balance"). Each closure
> has been stored in a global variable ("get-balance", "deposit").
> Each of the closures supports the method "apply". One requires that
> the ordered set of argument values be empty; the other requires that
> the ordered set of argument values be a singleton set.
>
Yes, I see what you mean now. Thanks...
Matt
--
Matt Hellige matt@immute.net
http://matt.immute.net