racket
racket copied to clipboard
Add `get-failure-result` to racket/function
This adds a very simple function named get-failure-result to racket/function. It is essentially just
(define (get-failure-result v)
(if (procedure? v) (v) v))
except that the version in this PR also includes an explicit arity check.
Since this function is so simple, the convenience it affords is obviously extremely minor. Still, I’ve written it so many times that it feels worth putting somewhere, especially since we already have failure-result/c.
the version in this PR also includes an explicit arity check
I have also written this function multiple times, but I think I have rarely if ever implemented an explicit arity check. That seems quite useful for cases when the argument isn't already protected by failure-result/c. It might be worth adding an optional #:who argument for even better error reporting in such cases.