What to do for bad arguments to foreign-status-plist? hga@xxxxxx (10 Aug 2020 15:10 UTC)
Re: What to do for bad arguments to foreign-status-plist? Lassi Kortela (10 Aug 2020 15:14 UTC)
Re: What to do for bad arguments to foreign-status-plist? Lassi Kortela (10 Aug 2020 15:38 UTC)
Re: What to do for bad arguments to foreign-status-plist? Lassi Kortela (14 Aug 2020 13:31 UTC)
Promise objects Lassi Kortela (14 Aug 2020 13:46 UTC)
Re: Promise objects Lassi Kortela (14 Aug 2020 14:04 UTC)

Re: Promise objects Lassi Kortela 14 Aug 2020 14:03 UTC

> (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)))