[plt-scheme] How to use syntax case?

From: Grant Rettke (grettke at acm.org)
Date: Mon May 28 16:01:35 EDT 2007

I'm starting with syntax case from zero. My end goal is to read a file
and extract a definition by name, for example "define impl1" so that I
can include it in another document.

Reading about syntax objects and playing around with the results of
read-syntax I can see what I want, because when printf it or call
(syntax-object->datum impl1-stx) on it I see that function:

(define impl1
  (λ (max)
    (let loop ((x 1) (y 2) (sum 0))
      (let* ((new-x y) (new-y (+ x y)) (new-sum (if (even? y) (+ sum y) sum)))
        (cond ((> y max) sum) (else (loop new-x new-y new-sum)))))))

It seems like I can use syntax-case to analyze each syntax object in
the list read in and try to match on impl1. The only problem is that
I've got absolutely no idea how to do this.

Where do I start?

Disclaimer, I have read the documentation and played around with the
code, read a few web articles, but I haven't dug around in collects
yet to see how folks use it there.

Posted on the users mailing list.