Subject: Re: Lisp and Scheme
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 30 Oct 2000 02:40:40 GMT
Newsgroups: comp.lang.scheme
Message-ID: <8tin38$993tp$1@fido.engr.sgi.com>
Bruce Hoult  <bruce@hoult.org> wrote:
+---------------
| In Dylan I'd just do:
| define constant (gen, gen2) =
|   block()
|     let x = 1;
|     values(method () x := x + 1 end,
|            method () x := x - 1 end)
|   end;
+---------------

FWIW, that variant works in MzScheme, too:

	> (define-values (gen gen2)
	    (let ((x 1))
	      (values (lambda () (set! x (+ x 1)) x)
		      (lambda () (set! x (- x 1)) x))))
	> (gen)
	2
	> (gen)
	3
	> (gen)
	4
	> (gen2)
	3
	> 


-Rob

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043