[plt-scheme] How to use syntax case?

From: Tommy Nordgren (tommy.nordgren at comhem.se)
Date: Mon May 28 16:46:26 EDT 2007

On 28 maj 2007, at 22.01, Grant Rettke wrote:

> 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.
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
	Check out kent Dybwig, The Scheme programming Language, 3d ed,
ISBN 0-262-54148-3
------
What is a woman that you forsake her, and the hearth fire and the  
home acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the  
Dane women
Tommy Nordgren
tommy.nordgren at comhem.se





Posted on the users mailing list.