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