[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: good books on scheme?
a lambda expression (i.e. a procedure definition) returns a *closure*,
capturing the environment in which it was defined so that it can
execute in that environment when called.
example:
(define (make-counter)
(let ((x 0))
(lambda ()
(set! x (add1 x))
x)))
make-counter returns a procedure that, when called, increments the
value of its local variable x each time. Several procedures can be
defined using make-counter, but each one has access to its own local
x.
> (define counter1 (make-counter))
> (define counter1 (make-counter))
> (counter1)
1
> (counter1)
2
> (counter2)
1
> (counter1)
3
if you like "The Little Schemer" you should probably check out
"essentials of programming languages" by Daniel Friedman, Mitchell Wand, and
Christopher Haynes. A new edition was just released by MIT Press. I
haven't had a chance to evaluate it yet, though, so I can't comment on
it's quality.
>From a teaching perspective, Concrete Abstractions (Hailperin, Kaiser,
Knight; Brooks/Cole Publishing Company) and Simply Scheme (Harvey and
Wright; MIT Press) are both good books. However, they both fail the
"closure test". Interesting enough, Essentials of Programming
Languages *does* have it listed, though.
Also failing the "closure test" is the r5rs standards!
-bogo
On Feb 06, 2001 11:59, Tim Hanson wrote:
| hi, I read SICP a number of years ago and was mostly delighted, in stark
| contrast to a number of unimpressed reviewers cited in this space in the past
| couple weeks! :)
|
| my scheme skills, however, have atrophied considerably in the past few
| years, during which time I've been paid to do more "scripting" using ksh, awk,
| perl, and more recently MS's "windows script host" and "active server pages."
|
| i tried to follow a recent discussion which mentioned tail recursion and
| closures. i remember tail recursion from SICP, but had forgotten what a closure
| is and I didn't find it in the index of my old copy (nor in the index of "the
| little schemer", the only other book on scheme I have. ah, wait! the latter
| has "apply-closure" and I find what I wanted to know: a closure is "a
| non-primitive function"?)
|
| i was going to ask: can folks recommend good books on scheme, including ones
| that define "closure." i guess I can still ask that and can also appeal to
| the authors among you to include it in the index in your next editions! :)
|
| cheers,
|
| Tim Hanson
|
| --
| Sent through GMX FreeMail - http://www.gmx.net
|