notjack
2020-10-28 10:57:20

I sent a post to the mailing list about the guarded-block macro. I’m trying to make it more extensible but I hit some macrology issues and I’m looking for advice https://groups.google.com/g/racket-users/c/H-EppBmQ7oU/m/chEItxUGBwAJ


sorawee
2020-10-28 10:59:45

I suppose guard-block is the real macro that does the work, while guard is just a “dummy” form that guard-block will recognize it by its binding. Is that correct?


sorawee
2020-10-28 11:04:49

local-expand could work, but it looks really heavyweight. Another possibility is doing something similar to match expander (https://github.com/racket/racket/blob/master/racket/collects/racket/match/match-expander.rkt#L8)


notjack
2020-10-28 11:08:47

Yup, guard doesn’t do anything on its own, guard-block just searches for it


notjack
2020-10-28 11:08:58

I don’t really want to have to create some sort of define-guard-expander form though


notjack
2020-10-28 11:09:22

I’d rather just write regular macros with define-simple-macro that happen to expand into guard statements


sorawee
2020-10-28 11:15:49

Then, another similar macro that you might want to look into is define/private, which expands to (private ...) and (define ...).

(define ...) is also recognized specially (just like your guard) inside class.


notjack
2020-10-28 11:18:03

class does seem similar



sorawee
2020-10-28 11:22:59

(list+ 1 (define x 2) (add1 x)) => '(1 3)


notjack
2020-10-28 11:23:22

oooo interesting


notjack
2020-10-28 11:23:25

that does seem relevant


sorawee
2020-10-28 11:33:09