[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [plt-scheme] Defines in lets
On May 18, Max Hailperin wrote:
> There is nothing in standardized Scheme that neatly corresponds to
> what you are used to in Common Lisp. Various Scheme implementations
> have non-standard extensions to the language that do what you want.
> If you want to stay within the standardized language, the closest
> you can come is:
>
> (define set-x 'not-yet-set) ; or any other placeholder value
> (define read-x 'not-yet-set)
>
> (let ((x 0))
> (set! set-x (lambda (y) (set! x y)))
> (set! read-x (lambda () x)))
But if you're sticking with mzscheme, you can do this:
(define-values (set-x read-x)
(let ((x 0))
(values (lambda (y) (set! x y))
(lambda () x))))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!