A shortcut to answering my question would be to tell me that 
`with-quasisyntax` in the following paste already exists: 
http://pasterack.org/pastes/48885

== Context ==
In my current project, I have a macro that is doing a lot of work. (It is 
Typed Racket, but my question applies equally to untyped Racket.) This 
macro takes in a struct id, field ids, and field types. It generates the 
struct definition along with some serialization and deserialization 
machinery.

Then I encounter a new requirement: I want to be able to convert at least 
one these structs to an association list. (This differs from 
serialization.) The most obvious way to me is to add that functionality to 
my already-large macro. But it is getting difficult to maintain, and it 
feels like there should be a better way.

== Solution? ==
I came up with the approach in this paste, and it seems to work great: 
http://pasterack.org/pastes/48885 (Of course, if I had more structs I would 
make certain things reusable, it just demonstrates the concept.)

Custom syntax transformers also came to mind, but they seem a bit 
cumbersome for something that I don't intend to expose to external code.

I'm kind of surprised that it took me so long to discover this approach. 
Unless there is some nasty footgun that I haven't hit yet, I expect I'll be 
using this approach a lot in the future. But if it feels so right, then why 
haven't I seen it until now?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/fb025d15-f0f6-4955-957e-b5576fca3f96n%40googlegroups.com.

Reply via email to