efficiency of let used in a binding

From: Brian Denheyer <briand_at_soggy.aqua.com>
Date: Sun, 19 Oct 1997 19:59:36 -0700 (PDT)

I just caught myself doing the following :

(define (mouse-motion x y)
  (let ((new-x (transform x))
        (new-y (transform y)))
    ...))

(bind drawing "<Motion>" mouse-motion)


I don't understand how scheme allocates "local" variables. Is it a
c-like thing where it's pushed on the stack and then popped or is the
variable allocated and then when the routine returns the space must be
gc'ed.

Obviously if the space is being allocated then a procedure bound to
mouse motion could generate a _lot_ of allocation which would be very
inefficient.

Common sense says that local variables are implemented on the stack so
I'm OK and can continue to use let's in procedures which are being
used in event bindings.

If not, I suppose I would then have to declare variables in the
top-level env and use set! to change the values.

Please let me know.

Thanks

-- 
Brian Denheyer
briand_at_northwest.com
Received on Mon Oct 20 1997 - 03:57:38 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST