[plt-scheme] simple macro

From: djneu at att.net (djneu at att.net)
Date: Wed Mar 2 17:54:50 EST 2005

Duh!  

Sorry, hit reply to soon.

Anyway, I was trying to figure out why the macro
in the could below didn't work.

Cheers,
David

 -------------- Original message ----------------------
From: "David J. Neu" <djneu at att.net>
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> 
> 
> 
> 
> 
>  (define-syntax init
>   (syntax-rules ()
>     ((_ sym def) (cond ((assq (quote sym) args) => cadr)
>                        (else def)))))
> 
>  (define f
>    (lambda (x . args)
>      (let  ((y (init y 2)))
>        (printf "x=~a y=~a~n" x y))))
> 
> (f 1 '(y 3))
> 
> reference to undefined identifier: args
> /tmp/test.ss:3:42: args
> /tmp/test.ss:3:24: (assq (quote y) args)
> /tmp/test.ss:8:15: (let-values (((g28) (assq (quote y) args))) (if g28 (cadr 
> g28) (begin 2)))
> /tmp/test.ss:8:5: (let-values (((y) (let-values (((g28) (....))) (if g28 
> ....)))) (printf "x=~a y=~a~n" x y))
> 




Posted on the users mailing list.