[racket] generate-temporaries with source location?
I'd like the ability to generate a bunch of temporaries, but with
specific source locations. I'm having an awkward time fixing an
embarrassing bug in my chaining-compare library.
I have the following expression:
(with-syntax ([rhs-value (datum->syntax #f
(gensym 'rhs-value)
(list (syntax-source #'rhs)
(syntax-line #'rhs)
(syntax-column #'rhs)
(syntax-position #'rhs)
(syntax-span #'rhs)))])
...)
and I feel really cheesy doing the gensym here! I'd love to replace this with:
(with-syntax ([(rhs-value) (generate-temporaries #'(rhs)])
...)
except that the resulting temporary variable doesn't have the correct
source location of the input, and having the 'rhs-value' syntax have
the right source location is critical.
In my imagination, I'd like to be able to say:
(with-syntax ([(rhs-value) (generate-temporaries/locs #'(rhs) #'(rhs))])
...)
and have this hypothetical "generate-temporaries/locs" adopt the
source locations from the second argument. Is this easy to build, or
does such functionality already exist?