notjack
2020-1-11 09:49:25

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


notjack
2020-1-11 09:51:48

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)


samth
2020-1-11 21:10:14

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


notjack
2020-1-11 23:48:26

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


mflatt
2020-1-12 00:06:51

Yes


sorawee
2020-1-12 01:08:18

It’s a really useful function for data visualization