[racket] beginner question about macros

From: Răzvan Rotaru (razvan.rotaru at gmail.com)
Date: Mon Dec 5 10:37:42 EST 2011

Ok, I understand. If I make the identifiers available in the macro
definition scope, by importing the libraries, that would that make the
macro hygienic, right? I would still need to textually transform the
identifier, from X to setX. Can this be achieved by a simple
conversion from string to symbol?

Razvan

On 5 December 2011 17:24, J. Ian Johnson <ianj at ccs.neu.edu> wrote:
> Precisely. Hygiene guarantees that identifiers that are neither explicitly passed to a macro nor in the lexical scope of the macro definition will not be in the output of said macro. This is often too restrictive for macro writers, since we have naming conventions that we want to programmatically produce (consider struct). Thus we have datum->syntax.
>
> You have to be careful about abusing this capability, since unintuitive collisions can happen when you have two macros using one another that depend on unhygienic naming conventions.
> You should try to restrict your use of unhygienic macros to function definitions and not macro definitions.
>
> -Ian



Posted on the users mailing list.