# Macro to Make Identifiers from String Diagram

**URL:** <https://racket.discourse.group/t/macro-to-make-identifiers-from-string-diagram/2296>\
**Category:** Questions & Answers\
**Tags:** macro\
**Created:** [September 7, 2023, 4:56pm UTC](https://racket.discourse.group/t/macro-to-make-identifiers-from-string-diagram/2296 "2023-09-07T16:56:23Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [September 10, 2023, 3:27pm UTC](https://racket.discourse.group/t/macro-to-make-identifiers-from-string-diagram/2296/12 "2023-09-10T15:27:29Z")

</div>

> I’m still interested in a clear answer to the original question about why giving `$NAME` the lexical context of the passed-in syntax object is not enough.

I have attempted to give an explanation here:

> [@Macros expanding to definitions](https://racket.discourse.group/t/macros-expanding-to-definitions/2301):
>
> Macros expanding to definitions This post is about macros that expand into definitions. The examples will use syntax/parse, so all snippets work if they are preceded with: #lang racket (require (for-syntax racket/syntax syntax/parse)) Scope sets and bindings The first example is the macro define-a. 1 (define-syntax (define-a stx) 2 (syntax-parse stx 3 [(\_define-a expr) 4 #'(define a expr)])) 5 6 (define-a 42) 7 a ; unbound identifier The variable reference a on…

The problem in the original was the macro expansion used `name-pt` without  
adjusting the context. The identifiers were given a scope, so they could be used  
in the code returned from parse-diagram, but not where parse-diagram was called.

---

_[View the full topic](https://racket.discourse.group/t/macro-to-make-identifiers-from-string-diagram/2296)._
