Identifiers aren't symbols. You still have to use datum->syntax to make your 
manipulated symbols into identifiers. To introduce an identifier in the macro 
definition context, you would have to use the macro's name from the pattern:

(define-syntax (macro stx)
  (syntax-case stx ()
    [(macro args ...)
     (with-syntax ([x (datum->syntax #'macro 
'should-be-in-macro-definition-context)])
       ...code...)]))

Pinning down what hygiene is at a high level is a research question. Hygiene is 
currently defined to be what the syntax-case macro expander does ("Syntactic 
Abstraction in Scheme" ~Dybig '92).
The informal notion is that alpha-equivalence of macro inputs is preserved 
through expansion. The problem is that binding structure in a macro's input is 
only determined by macro expansion.

-Ian

----- Original Message -----
From: "Răzvan Rotaru" <razvan.rot...@gmail.com>
To: "J. Ian Johnson" <i...@ccs.neu.edu>
Cc: users@racket-lang.org
Sent: Monday, December 5, 2011 10:37:42 AM GMT -05:00 US/Canada Eastern
Subject: Re: [racket] beginner question about macros

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 <i...@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

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to