[plt-scheme] Problem with define-syntax. It is still not clear.

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Thu Jan 19 10:01:17 EST 2006

Andre-

> If you try the following code, it seems that the macro sees the  
> list (1 3) in both case but fails to match. In both case x should  
> be the list (1 3) and not (quote (1 3)). I don't understand why. I  
> guess the answer is simple but I can't find it after a few hours.

Macros do not work on runtime values of particular variables; they  
work on the compile-time syntax (that is, the program text itself).

So
	(testListe x)
is *ALL* that your macro is going to see in the uses that you posted;  
it doesn't get to find out what value x is bound to, because at  
compile-time (or technically, macro-expansion-time), x is just an  
identifier.

To better understand this, try doing:

(testListe (2 1))
(testListe (1 3))
(testListe 1 3)
(testListe 1)

and compare/contrast the results that you see.  (Don't be surprised  
by error messages; two of the expressions above will break when you  
evaluate them.)

One tutorial on syntax-rules is at:
	http://home.comcast.net/~prunesquallor/macro.txt
though you may not quite be at the right level for that yet.  Still,  
you can try looking at it.

-Felix



Posted on the users mailing list.