|
From: | Sunnan |
Subject: | Re: [Chicken-users] Re: Style Guide |
Date: | Wed, 07 Nov 2007 12:39:54 +0100 |
User-agent: | Thunderbird 2.0.0.6 (X11/20071022) |
Kon Lovett wrote:
I've used the idiom for more complex generators with multiple yield points but it quickly becomes tangled. I don't like the programming style that too many generators afford, so I don't do this so much. I usually use generator for generating ids where http://okmij.org/ftp/Scheme/monad-in-Scheme.html would use either a global variable or a state monad.(define (fib) (let loop ((a 1) (b 1)) (set! fib (lambda () (loop b (+ a b)))) a)) ;; maybe non-portable outside of current chicken semantics?Except for the caveat about some compilers, no. However the above doesn't "make" a generator, in the sense that it can be reused. To restart the sequence 'fib' must be rebound. Certainly not "disgusting", just of limited use.
Sunnan
[Prev in Thread] | Current Thread | [Next in Thread] |