[racket-dev] Identifier macros
I think two additions/refinements would be good here:
1. The section on identifier macros in the Guide (16.1.5) should mention that define-syntax introduces short-hands for identifiers, period. That is, the following interaction works perfectly fine:
> (define-syntax (foo stx) #'7)
> (+ foo 2)
9
> foo
7
2. Then the section should explain that it is the use of syntax-rule/syntax-rules/syntax-case/syntax-parse that forces stx to be in a certain shape. If foo is not defined with any of these features, the identifier alone triggers an expansion.
So, when define-syntax demands the use of syntax-parse (or friends) but you also want to use this identifier with a related meaning in an identifier position, you should use syntax-id-rules.
Does this make sense? -- Matthias
On Dec 5, 2012, at 7:23 AM, Matthew Flatt wrote:
> I'd like to improve the documentation, but I can't tell which part
> you're talking about. (The only place where I can find "identifier
> macros" is in the Guide, but that's about `syntax-rules' versus
> `syntax-id-rules'.) Can you point to the part that you're reading and
> the specific text that seems misleading?
>
> At Tue, 4 Dec 2012 17:16:17 -0500, Carl Eastlund wrote:
>> I'm confused about so-called "identifier macros". I had thought that
>> ordinary transformers bound to functions could only transform
>> application-position references to themselves, and that a "set!
>> transformer" was required to transform bare references and set!
>> references. Turns out I was wrong, set! transformers are in fact only
>> required to transform set! references. So why are they listed under the
>> documentation for "identifier macros" and why does that documentation imply
>> that normal transformers can't handle bare references?
>>
>> Carl Eastlund
>> _________________________
>> Racket Developers list:
>> http://lists.racket-lang.org/dev
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20121205/85739169/attachment-0001.p7s>