Obviously this can be fooled, like
(force (let loop () (delay-force (loop))))
or any non-halting Turing machine, but this is an easy case to detect
with negligible cost.
value
(let ((promise* (value)))
(guarantee promise? promise* 'force)
+ (if (eq? promise* promise)
+ (error "Infinite recursion in promise:" promise))
(without-interrupts
(lambda ()
(let ((q (cell-contents promise)))
(define-test 'delay-force-loop
(lambda ()
- (expect-failure
+ (assert-error
(lambda ()
- (assert-error
- (lambda ()
- (carefully (lambda ()
- (define p (delay-force p))
- (force p))
- (lambda () 'stack-overflow)
- (lambda () 'timeout))))))))
+ (carefully (lambda ()
+ (define p (delay-force p))
+ (force p))
+ (lambda () 'stack-overflow)
+ (lambda () 'timeout))))))
(define-test 'force-force-delay-delay
(lambda ()