some scheme compilers will allocate some local vars on the
stack, but most scheme interpreters (such as Stk) don't do
it at all, because it's hard to tell if it's safe to do so.
but I wouldn't worry too much about it. in this code:
> (define (mouse-motion x y)
> (let ((new-x (transform x))
> (new-y (transform y)))
> ...))
> (bind drawing "<Motion>" mouse-motion)
you're already getting heap allocation on every
mouse-motion, for the vars 'x' and 'y'.
if you discover that heap usage here really matters, reuse x
and y instead of using new-x and new-y. or use global vars
(but make sure you use random 256-char names to avoid name
clashes :)
(it's hard for scheme to put vars on the stack because local
vars can escape their block. for example, in
(define (make-adder x)
(define (add-x y)
(+ x y))
add-x)
(define add-1 (make-adder 1))
the local binding x => 1 has to survive as long as add-1
survives.)
--
Received on Mon Oct 20 1997 - 07:45:30 CEST