dyllongagnier
2021-1-25 18:16:28
For example, you would write
(define-inline (loop-range stop proc)
(let loop ([n 0])
(unless (>= n stop)
(proc n)
(loop (add1 n)))))
(let/ec return
(define result 0)
(loop-range benchmark-range
(lambda (n)
(when (>= n benchmark-break)
(return result))
(set! result (+ n result)))))
dyllongagnier
2021-1-25 18:18:33
In my actual benchmark, loop-range was in a different module than the let/ec. I also saved the result to a variable to avoid optimizing the loop completely away.