This is kind of a kluge, I know. But you get the idea. Let over
lambda, because we're going to be reusing these procedures over and over
again across multiple calls.
Now let's say I instantiate this like:
(define my-methods
(methods
[(double x)
(* x x)]))
That's the line where method-dispatch is defined, inside the macro.
But what I really want is for the annotation on the procedure to be where my-methods is defined.... not pointing back inside the macro.
where loc-stx is a syntax object whose source location is the location, you want to
give to the lambda expression.
In your macro that location comes from the application of method. That means method needs to send the location along to method*. One of way doing so is shown below.
If you want both mehod* and method to be available to the user, then adding an argument to method* might not be desirable. In that case, rename method* above to, say, do-method* and define two macros method and method* which both expands to do-method*.
FWIW, I gave a similar solution, along with another solution that uses syntax-local-name in the mailing list, which, with high probability, probably went to the spam folder.