This is the situation: I have a class definition whose public methods are defined using macro's. The methods look something like this:
<-- macro definition surrounds this method -->
(define/public (message-identifier parameters state-values)
message-body ...) ...
where all variables (message-identifier, parameters, and state-values) are part of the macro expansion. message-bodyis a sequence of expressions like you would expect in a regular method body (generated by the macro expansion). The body of the method may contain some forms that also expand, for example, if you would want to explicitly state return values, the expression (return 1) may be part of the body, to which we could apply (for example) this rule:
(define-syntax-rule (return value)
(displayln "i should return a value!"))
I would like to know in the definition of the class method when, in this case, a return statement is included in the body of the method. So could I for example dynamically bind a variable? This example does not work, but it brings accross the idea.
(define/public (message-identifier parameters state-values)
(define return-included? #t)
message-body ...) ...
(define-syntax-rule (return value)
(begin (set! return-included? value) ; 'return-included?' is undefined
(displayln "i should return a value!")))
Or could I maybe do fancy stuff with macros in the macro that expands the body of the method, instead of having a separate macro for the return statement?
Thank you