[racket] Splicing nested syntax clauses

From: Jack Firth (jackhfirth at gmail.com)
Date: Fri Jun 27 15:47:44 EDT 2014

I'm working with some servlet dispatching code and I want to be able to use
dispatch-rules to generate the url to response mappings, but I want to be
able to group related handlers to subpages. Under dispatch-rules, that
looks something like this:

(dispatch-rules
    [("page-a" "handler-a" (integer-arg)) handler-a]
    [("page-a" "handler-b" (integer-arg)) handler-b]
    [("page-b" "handler-c" (integer-arg)) handler-c]
    [("page-b" "handler-d" (integer-arg)) handler-d])

What I want is to be able to specify a tree structure of some sort like
this:

(my-dispatch-rules
    [(my-dispatch-rules "page-a"
        [("handler-a" (integer-arg)) handler-a)]
        [("handler-b" (integer-arg)) handler-b)]
    [(my-dispatch-rules "page-b"
        [("handler-c" (integer-arg)) handler-c)]
        [("handler-d" (integer-arg)) handler-d)])

And have that expand, placing the page-a and page-b bits in the appropriate
areas. From what I understand of macros, the appropriate way to do this is
with quasiquoting and splicing unquotes, but I can't seem to figure out
using splicing with syntax-case, and the various tutorials and
documentation I've looked at haven't helped me really wrap my head around
the specifics. If someone could point me towards enlightenment, that would
be much appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140627/9e120f31/attachment-0001.html>

Posted on the users mailing list.