Things are getting a bit clearer. Thank you all for your time and patience with stubborn learners ;)<br>Laurent<br><br><div class="gmail_quote">On Sun, Jan 10, 2010 at 08:17, Eli Barzilay <span dir="ltr"><<a href="mailto:eli@barzilay.org">eli@barzilay.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Jan 9, Laurent wrote:<br>
><br>
> For the sake of it, here it is (yes, with `apply'):<br>
</div>> [...]<br>
<br>
So, as I suspected, your problem was independent of `defmacro', and<br>
doing this exercise would have made that clear.<br>
<div class="im"><br>
<br>
> My main problem is that `syntax-rules', `syntax-case', `with-syntax'<br>
> and others that I have not used yet use the syntax in quite<br>
> different ways, and sometimes you have to #' and sometimes you have<br>
> to (syntax->datum ....) and sometimes not. I have a hard time to<br>
> know when to use the right one at the right time (the docs are a bit<br>
> obscure on these points). Whereas in `defmacro', I know exactly<br>
> when to use `quote' and `unquote'.<br>
<br>
</div>Using `define-syntax' is practically the same -- it just uses syntax<br>
objects instead of "plain" datums. This means that there's an extra<br>
layer to dig through if you want to do some games like create your own<br>
identifiers -- and this extra layer is needed because it's how you get<br>
complete control over the lexical scope of the macro results.<br>
`defmacro' is kind of like throwing plain symbols around and hoping<br>
that the scope will be right -- and in almost all cases the scope is<br>
only partially right.<br>
<br>
[It takes a while to run into cases where it's not right -- and once<br>
you get burned by that you gain important insight on why hugiene is<br>
important. As someone pointed out earlier, the fact that the defmacro<br>
version uses whatever `define' happens to be in the scope of the macro<br>
use is a good example for that -- all it takes is a language with<br>
different semantics for `define', and the `defmacro' version will fall<br>
apart in surprisingly hard to debug ways.]<br>
<div class="im"><br>
<br>
> Wouldn't it be possible to define "safe" quotes and unquotes for<br>
> syntax macros, without having to go from syntax to datum and<br>
> vice-versa at weird places? [...]<br>
<br>
</div>I don't think so. (And like Matthias said, if there is some way to do<br>
that, it hasn't been discovered yet.)<br>
<br>
This is also relevant here:<br>
<br>
<a href="http://blog.plt-scheme.org/2009/05/explicit-renaming-macros-implicitly.html" target="_blank">http://blog.plt-scheme.org/2009/05/explicit-renaming-macros-implicitly.html</a><br>
<div><div></div><div class="h5"><br>
--<br>
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:<br>
<a href="http://barzilay.org/" target="_blank">http://barzilay.org/</a> Maze is Life!<br>
</div></div></blockquote></div><br>