
As part of my current project, I wound up writing this wrapper around impersonate-procedure
and chaperone-procedure
that tries to make the API a little easier to work with: (define (function-impersonate function
#:guard [guard #f]
#:properties [props (hash)]
#:application-marks [marks (hash)]
#:chaperone? [chaperone? (false? guard)])
(define impersonator-factory
(if chaperone? chaperone-procedure impersonate-procedure))
(define prop-args (impersonator-properties->positional-arguments props))
(define mark-args
(for*/list
([(k v) (in-immutable-hash props)]
[element
(in-list (list impersonator-prop:application-mark (cons k v)))])
element))
(apply impersonator-factory function guard (append prop-args mark-args)))

For example, this: (chaperone-procedure f wrapper impersonator-prop:x 'x impersonator-prop:y 'y)
is equivalent to: (define props (hash impersonator-prop:x 'x impersonator-prop:y 'y))
(function-impersonate f #:guard wrapper #:properties props #:chaperone? #t)

@mflatt in your recent commit, I assume that the bars are relative runtime with smaller better?

Anyone have a demand for something like this? > (range-clamp (closed-range 1 9) 4)
4
> (range-clamp (closed-range 1 9) 8000)
9
> (range-clamp (closed-range 1 9) -8000)
1

Yes

It’s a really useful function for data visualization