Re: efficiency of let used in a binding

From: David Fox <fox_at_cat.nyu.edu>
Date: 21 Oct 1997 05:34:55 -0400

Brian Denheyer <briand_at_soggy.aqua.com> writes:

> > In the given situation, rewriting the program as
> >
> > (define (mouse-motion x y)
> > (set! new-x (transform x))
> > (set! new-y (transform y))
> > ...)
> >
>
> Dumb question, but, I assume I want new-x and new-y to be globals ?
>
> Also - the other solution is - if the routine is living inside another, i.e.
>
> (define foo
> ...
> (define (mouse-motion
> ...
>
> Then I should be able to declare variables inside foo, and then use
> set!. This solves the name-space problem and the allocation problem
> at the same time, does it not ??

One could write

(define mouse-motion
  (let ((new-x #f) (new-y #f))
    (lambda (x y)
      (set! new-x (transform x))
      (set! new-y (transform y))
      ...)))

There is some disagreement about what define means when it is not
at the top level.
-- 
David Fox            http://www.cat.nyu.edu/fox            xoF divaD
NYU Media Research Lab     fox_at_cat.nyu.edu    baL hcraeseR aideM UYN
Received on Tue Oct 21 1997 - 10:33:56 CEST

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