[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>]
> 
> A closure is an object that supports exactly one method: "apply".
> 

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)))


Matt

-- 
Matt Hellige                  matt@immute.net
http://matt.immute.net