On Nov 6, 2007, at 6:30 AM, Sunnan wrote:
Jörg F. Wittenberger wrote:
For pure chicken code this maybe correct.
But some Scheme implementations happen to treat the former form as a
global variable, which can be set! later on, while the latter is
beeing
compiled into a static binding and set! on it will raise an error.
Thanks for this clarification, I didn't know that.
However, since I only seldomly use set! on functions, I guess I'd
prefer the latter form anyway.
One notable exception is this (disgusting?) idiom I invented for
making generators without call/cc yield:
(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.
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users
Best Wishes,
Kon
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users