> (define (plist-value-pair plist property)
> (cond ((not (and (pair? plist) (pair? (cdr plist))))
> #f)
> ((eq? property (car plist))
> (cdr plist))
> (else
> (plist-value-pair (cddr plist) property))))
[...]
> (define (foreign-status-ref st property)
> (let ((pair (plist-value-pair (%foreign-status-plist st) property)))
> (and pair
> (begin (if (promise? (car pair))
> (set-car! pair (force (car pair))))
> (car pair)))))
Nevermind, RnRS says promises even take care to be evaluated only once.
So we don't even need to account for that. This would do:
(define (foreign-status-ref st property)
(let ((value (plist-ref/default (%foreign-status-plist st) property #f)))
(if (promise? value) (force value) value)))