
Made a neat macro that I think this channel would be interested in: (guarded-block
(define x (random 10))
(guard (even? x)
(define message-template "X was even, X = ~a, returning early")
(format message-template x))
(define y (random 10))
(guard (odd? y)
(define message-template "Y was odd, Y = ~a, returning early")
(format message-template y))
(+ x y))

the above expands into this: (block
(define x (random 10))
(cond
[(even? x)
(define message-template "X was even, X = ~a, returning early")
(format message-template x)]
[else
(define y (random 10))
(cond
[(odd? y)
(define message-template "Y was odd, Y = ~a, returning early")
(format message-template y)]
[else (+ x y)])]))

I have been using a binding form defr
(short for define-random). A short example with just one clause:
(defr [(x y) (random 1 10)] #:where (> (+ x y) 5)])
This computes two random numbers and binds them to x and y. Then checks if the predicate (> (+ x y) 5)
. If true we carry on, if not, a new set of numbers are generated until we find a pair that fullfills the predicate.

The form is useful, when you need to generate a set of numbers that needs to be in some relation to each other.

I like that you guarded-block
has an expansion without let/ec
.

Yeah I really want to avoid paying the cost of continuations

I think this version is something we could add directly to racket and make define
support automatically