Talk:Hygienic macro
From Wikipedia, the free encyclopedia
Macros transform arguments into call by reference? Weird. orthogonal 19:25, 20 Nov 2003 (UTC)
-- No, macros transform code before it hits the compiler or interpreter. There's no references at all, at macro expansion time, all you have available as arguments are tokens. -BrianCully 14:54, 2 September 2006 (UTC)
[edit] Examples
It's great that there's a C example here, but I've never heard anybody speak of hygienic macros in the context of C -- only in dialects of Lisp. Could we get (1) a similar example of the hygiene problem in Common Lisp, (2) the same example in Scheme (which claims to have hygienic macros), and (3) how a Common Lisper would resolve the problem? Thanks!
I have to admit, I don't follow any of these examples. It seems to me, in the lisp example, it's doing exactly what you would want and expect. Consider the following:
(defun foo (x) (- x 3)) (flet ((foo (x) x)) (foo 4)) => 4
So, wouldn't you expect that when you over-ride not to not be not at all, your unless breaks? The only reason this works with not is because its special, but you can still over-ride it with macrolet:
(macrolet ((not (x) x)) (unless t (format t "This should not be printed.~%")))
On top of that, trying to run the example code in OpenMCL produces:
;Compiler warnings : ; Attempt to bind compiler special name: NOT. Result undefined, in an anonymous lambda form.
-BrianCully 14:54, 2 September 2006 (UTC)