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