# \#macro

**URL:** https://racket.discourse.group/tag/macro/28.md?page=1

[Latest](https://racket.discourse.group/latest.md) · [Categories](https://racket.discourse.group/categories.md) · [Tags](https://racket.discourse.group/tags.md)

**Page:** 2

---

## [How to match up macro-generated and user-defined identifiers?](https://racket.discourse.group/t/how-to-match-up-macro-generated-and-user-defined-identifiers/2379)

<div class="topic-metadata">

**Author:** [@pcn](https://racket.discourse.group/u/pcn)\
**Replies:** 2\
**Last updated:** [October 13, 2023, 4:11am UTC](https://racket.discourse.group/t/how-to-match-up-macro-generated-and-user-defined-identifiers/2379 "2023-10-13T04:11:19Z")

</div>

The question is likely very basic. I'm just rusty :grin: I'm trying to implement poor man's module that can be parameterized by types, using structs. An example is I can do something like: (define-signature (expr E) …

---

## [Splicing in syntax](https://racket.discourse.group/t/splicing-in-syntax/2336)

<div class="topic-metadata">

**Author:** [@mem](https://racket.discourse.group/u/mem)\
**Replies:** 4\
**Last updated:** [September 23, 2023, 12:55pm UTC](https://racket.discourse.group/t/splicing-in-syntax/2336 "2023-09-23T12:55:19Z")

</div>

Be gentle, folks—first time posting here. I've been interested in DSLs for a long time, and when I get the itch I come back to Racket to fool around a bit and inevitably find myself tangled up in some issue or another. …

---

## [Macro Expressiveness and Nesting](https://racket.discourse.group/t/macro-expressiveness-and-nesting/2313)

<div class="topic-metadata">

**Author:** [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Replies:** 0\
**Last updated:** [September 15, 2023, 3:27pm UTC](https://racket.discourse.group/t/macro-expressiveness-and-nesting/2313 "2023-09-15T15:27:17Z")

</div>

Hi, Racket Discourse. Might be I'm overthinking the situation, but I thought I would ask anyway. Is there a known theorem/result/conjecture about the expressiveness of macros, in terms of how many layers of nesting you…

---

## [Macro Monstrosity: Some Questions](https://racket.discourse.group/t/macro-monstrosity-some-questions/2311)

<div class="topic-metadata">

**Author:** [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Replies:** 5\
**Last updated:** [September 15, 2023, 2:45pm UTC](https://racket.discourse.group/t/macro-monstrosity-some-questions/2311 "2023-09-15T14:45:09Z")

</div>

Hi, Racket Discourse. I am busy writing an "interface" which allows me to use a macro-defined template to access the content of the equivalents of JSON objects, i.e., hasheq tables, returned by http-easy's response-json …

---

## [Macro to Make Identifiers from String Diagram](https://racket.discourse.group/t/macro-to-make-identifiers-from-string-diagram/2296)

<div class="topic-metadata">

**Author:** [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Replies:** 11\
**Last updated:** [September 10, 2023, 3:27pm UTC](https://racket.discourse.group/t/macro-to-make-identifiers-from-string-diagram/2296 "2023-09-10T15:27:29Z")

</div>

Hi, Racket Discourse. I am trying to write a macro using some bits of beautiful-racket so that I can provide a string encoding of a diagram and convert the letter names in the diagram to identifiers which are used to de…

---

## [Macros expanding to definitions](https://racket.discourse.group/t/macros-expanding-to-definitions/2301)

<div class="topic-metadata">

**Author:** [@soegaard](https://racket.discourse.group/u/soegaard)\
**Replies:** 0\
**Last updated:** [September 10, 2023, 3:23pm UTC](https://racket.discourse.group/t/macros-expanding-to-definitions/2301 "2023-09-10T15:23:30Z")

</div>

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/synt…

---

## [Syntax parameter encapsulation](https://racket.discourse.group/t/syntax-parameter-encapsulation/2119)

<div class="topic-metadata">

**Author:** [@notjack](https://racket.discourse.group/u/notjack)\
**Replies:** 5\
**Last updated:** [July 20, 2023, 4:44pm UTC](https://racket.discourse.group/t/syntax-parameter-encapsulation/2119 "2023-07-20T16:44:58Z")

</div>

For a long time now, when I've wanted an "anaphoric macro" I've used syntax parameters. Consider a library that defines a define/return macro for defining functions that can be short circuited using return. The way I'd …

---

## [Question regarding head patterns in macros generating macros](https://racket.discourse.group/t/question-regarding-head-patterns-in-macros-generating-macros/2088)

<div class="topic-metadata">

**Author:** [@jschappel](https://racket.discourse.group/u/jschappel)\
**Replies:** 1\
**Last updated:** [July 10, 2023, 6:56pm UTC](https://racket.discourse.group/t/question-regarding-head-patterns-in-macros-generating-macros/2088 "2023-07-10T18:56:18Z")

</div>

Hello :wave:! I am messing around with racket macros and I have a question regarding macros generating macros. I originally created a simple macro that creates a local binding which allows rackets define syntax and limit…

---

## [Share your favourite macros that you've written!](https://racket.discourse.group/t/share-your-favourite-macros-that-youve-written/2017)

<div class="topic-metadata">

**Author:** [@priime0](https://racket.discourse.group/u/priime0)\
**Replies:** 5\
**Last updated:** [July 6, 2023, 9:49pm UTC](https://racket.discourse.group/t/share-your-favourite-macros-that-youve-written/2017 "2023-07-06T21:49:18Z")

</div>

I'm curious to see the macros others have written. :slight\_smile:

---

## [Question About Macro Bindings](https://racket.discourse.group/t/question-about-macro-bindings/2033)

<div class="topic-metadata">

**Author:** [@jschappel](https://racket.discourse.group/u/jschappel)\
**Replies:** 6\
**Last updated:** [June 21, 2023, 3:50pm UTC](https://racket.discourse.group/t/question-about-macro-bindings/2033 "2023-06-21T15:50:06Z")

</div>

Hello :wave:! I am tying to write 2 simple macros where one renames a identifier by appending $ to the beginning and end. The other returns the newly created identifiers in a list. #lang racket (require (for-syntax syn…

---

## [\[PADL'23\] Modern Macros](https://racket.discourse.group/t/padl23-modern-macros/1805)

<div class="topic-metadata">

**Author:** [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Replies:** 10\
**Last updated:** [March 27, 2023, 11:38pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805 "2023-03-27T23:38:12Z")

</div>

\[PADL'23\] Modern Macros Keynote by Robby Findler https://youtu.be/YMUCpx6vhZM Description: Modern Macros Racket’s approach to macros is the latest point in an evolution that started in 1963 with Lisp’…

---

## [Macro in Racket language?](https://racket.discourse.group/t/macro-in-racket-language/1709)

<div class="topic-metadata">

**Author:** [@Antigen-11](https://racket.discourse.group/u/Antigen-11)\
**Replies:** 7\
**Last updated:** [February 13, 2023, 3:09pm UTC](https://racket.discourse.group/t/macro-in-racket-language/1709 "2023-02-13T15:09:37Z")

</div>

\> (version) "8.8" \> (require (for-syntax racket/base)) \> (define-syntax-rule (make-module n (l ...) i b) (module n racket/base (require l ...) (provide i) (define i b))) \> (make-module t () x 1) str…

---

## [Macro Output Spliced into Context](https://racket.discourse.group/t/macro-output-spliced-into-context/1641)

<div class="topic-metadata">

**Author:** [@Liam.Gaudy](https://racket.discourse.group/u/Liam.Gaudy)\
**Replies:** 9\
**Last updated:** [January 17, 2023, 5:13pm UTC](https://racket.discourse.group/t/macro-output-spliced-into-context/1641 "2023-01-17T17:13:07Z")

</div>

I was just about to give up on doing the below, when I thought it might be fun for a more experienced person to offer advice. I have this repetitive cond for a comparator, with my thanks to @notjack for writing such impo…

---

## [Failed to match syntax-case for some literal names if using read-syntax](https://racket.discourse.group/t/failed-to-match-syntax-case-for-some-literal-names-if-using-read-syntax/1583)

<div class="topic-metadata">

**Author:** [@corpix](https://racket.discourse.group/u/corpix)\
**Replies:** 1\
**Last updated:** [December 28, 2022, 1:54am UTC](https://racket.discourse.group/t/failed-to-match-syntax-case-for-some-literal-names-if-using-read-syntax/1583 "2022-12-28T01:54:20Z")

</div>

Hi. Can't understand why I can't match some literal-id's with syntax-case. Here is a successful match example: \> (let ((stx #'(load 'hello))) (syntax-case stx (load) ((load expr) (syntax expr)))) #\<syntax::73…

---

## [Error 'unbound identifier' while read-syntax on expand phase](https://racket.discourse.group/t/error-unbound-identifier-while-read-syntax-on-expand-phase/1582)

<div class="topic-metadata">

**Author:** [@corpix](https://racket.discourse.group/u/corpix)\
**Replies:** 1\
**Last updated:** [December 27, 2022, 11:16pm UTC](https://racket.discourse.group/t/error-unbound-identifier-while-read-syntax-on-expand-phase/1582 "2022-12-27T23:16:21Z")

</div>

Hi! I have a problem which I could not wrap my head around... There is an error 'unbound identifier' in transform stage when I try to load some configuration with 'read-syntax'. This works at runtime stage. What I try …

---

## [Wrap a macro injecting bindings in another macro](https://racket.discourse.group/t/wrap-a-macro-injecting-bindings-in-another-macro/1406)

<div class="topic-metadata">

**Author:** [@scolobb](https://racket.discourse.group/u/scolobb)\
**Replies:** 4\
**Last updated:** [November 2, 2022, 5:49pm UTC](https://racket.discourse.group/t/wrap-a-macro-injecting-bindings-in-another-macro/1406 "2022-11-02T17:49:03Z")

</div>

Hi, I have in my toolbox the macro auto-hash-ref/:, defined here. Essentially, the idea is to automatically search for a variable value in a hash table. For example: (define ht (hash 'a 1 'b 2)) (auto-hash-ref/: ht (…

---

## [Syntax-local-introduce and module boundaries](https://racket.discourse.group/t/syntax-local-introduce-and-module-boundaries/1157)

<div class="topic-metadata">

**Author:** [@Kalimehtar](https://racket.discourse.group/u/Kalimehtar)\
**Replies:** 7\
**Last updated:** [July 28, 2022, 5:47pm UTC](https://racket.discourse.group/t/syntax-local-introduce-and-module-boundaries/1157 "2022-07-28T17:47:38Z")

</div>

If I use syntax-local-introduce inside one module, then it works: (define-syntax (require-macro stx) (syntax-local-introduce #'(require racket/math))) (define-syntax (define-macro stx) (syntax-local-introduce #'(de…

---

## [Macro Template Syntax Quasi-Quote with Ellipses](https://racket.discourse.group/t/macro-template-syntax-quasi-quote-with-ellipses/1179)

<div class="topic-metadata">

**Author:** [@Liam.Gaudy](https://racket.discourse.group/u/Liam.Gaudy)\
**Replies:** 5\
**Last updated:** [July 25, 2022, 10:57pm UTC](https://racket.discourse.group/t/macro-template-syntax-quasi-quote-with-ellipses/1179 "2022-07-25T22:57:33Z")

</div>

I'm using the below as an example to ask the question. Please recall that case works like this: (case (+ 7 5) \[( 1 2 3) 'small\] \[( 10 11 12) 'big\]) Let's say I never need more than one match for the same body.…

---

## [\`with-editor-sequence\`](https://racket.discourse.group/t/with-editor-sequence/1125)

<div class="topic-metadata">

**Author:** [@benknoble](https://racket.discourse.group/u/benknoble)\
**Replies:** 1\
**Last updated:** [July 6, 2022, 10:24pm UTC](https://racket.discourse.group/t/with-editor-sequence/1125 "2022-07-06T22:24:38Z")

</div>

I almost can't believe this isn't in the standard library, so here it is: (define (call-with-editor-sequence editor f) (send editor begin-edit-sequence) (f) (send editor end-edit-sequence)) (require syntax/parse/…

---

## [Function and macro to define unique values](https://racket.discourse.group/t/function-and-macro-to-define-unique-values/1097)

<div class="topic-metadata">

**Author:** [@sschwarzer](https://racket.discourse.group/u/sschwarzer)\
**Replies:** 9\
**Last updated:** [June 27, 2022, 5:29am UTC](https://racket.discourse.group/t/function-and-macro-to-define-unique-values/1097 "2022-06-27T05:29:33Z")

</div>

I've seen the idiom (struct unique-value ()) to create unique values, for example as default arguments in a function to check with (eq? argument unique-value) if anything was passed for the argument. Since I have only…

---

## [Is this macros pair possible?](https://racket.discourse.group/t/is-this-macros-pair-possible/1048)

<div class="topic-metadata">

**Author:** [@Kalimehtar](https://racket.discourse.group/u/Kalimehtar)\
**Replies:** 2\
**Last updated:** [June 2, 2022, 3:45pm UTC](https://racket.discourse.group/t/is-this-macros-pair-possible/1048 "2022-06-02T15:45:18Z")

</div>

I would like to make something like (my-if cond1 act1 ...) (my-else act2 ...) that should expand to (if cond1 (begin act1 ...) (begin act2 ...)) Is it possible?

---

## [Factor out parts of syntax templates](https://racket.discourse.group/t/factor-out-parts-of-syntax-templates/800)

<div class="topic-metadata">

**Author:** [@scolobb](https://racket.discourse.group/u/scolobb)\
**Replies:** 11\
**Last updated:** [May 31, 2022, 1:33pm UTC](https://racket.discourse.group/t/factor-out-parts-of-syntax-templates/800 "2022-05-31T13:33:11Z")

</div>

Hi, I have a couple macros which produce very similar syntaxes, with some changes. I would like to factor out parts of those templates to reduce code duplication. Essentially, I would like to do something like this: (…

---

## [Macro generating definitional macro](https://racket.discourse.group/t/macro-generating-definitional-macro/1004)

<div class="topic-metadata">

**Author:** [@rockn](https://racket.discourse.group/u/rockn)\
**Replies:** 4\
**Last updated:** [May 20, 2022, 10:24am UTC](https://racket.discourse.group/t/macro-generating-definitional-macro/1004 "2022-05-20T10:24:45Z")

</div>

Hi, (define-syntax-rule (define-define-macro m id) (define-syntax-rule (m) (define id (lambda (x) x)))) (define-define-macro m1 id1) (m1) (id1 2) Why is id1 unbound while (define-syntax-rule (m2 id) (define …

---

## [How to best implement something like "defer"' in Go?](https://racket.discourse.group/t/how-to-best-implement-something-like-defer-in-go/723)

<div class="topic-metadata">

**Author:** [@slaymaker1907](https://racket.discourse.group/u/slaymaker1907)\
**Replies:** 15\
**Last updated:** [May 10, 2022, 9:41pm UTC](https://racket.discourse.group/t/how-to-best-implement-something-like-defer-in-go/723 "2022-05-10T21:41:04Z")

</div>

I was wondering if anyone had any ideas for how to elegantly implement something like defer in Racket which executes either at the end of the current scope and/or the end of the current function? Obviously, this isn't t…

---

## [Why can this program not find its own macro call site?](https://racket.discourse.group/t/why-can-this-program-not-find-its-own-macro-call-site/976)

<div class="topic-metadata">

**Author:** [@slg](https://racket.discourse.group/u/slg)\
**Replies:** 1\
**Last updated:** [May 7, 2022, 2:41am UTC](https://racket.discourse.group/t/why-can-this-program-not-find-its-own-macro-call-site/976 "2022-05-07T02:41:51Z")

</div>

EDIT: After reviewing the docs, it seems that syntax-position is one-based with respect to the code read from the file. Not sure why the syntax-position in the macro definition appears to be zero-based. Also: edited this…

---

## [Opinions on \`quasiquote\`..\`unquote\` matching up when not lexically together?](https://racket.discourse.group/t/opinions-on-quasiquote-unquote-matching-up-when-not-lexically-together/784)

<div class="topic-metadata">

**Author:** [@rocketnia](https://racket.discourse.group/u/rocketnia)\
**Replies:** 3\
**Last updated:** [March 13, 2022, 9:20am UTC](https://racket.discourse.group/t/opinions-on-quasiquote-unquote-matching-up-when-not-lexically-together/784 "2022-03-13T09:20:12Z")

</div>

I've been building a library, Punctaffy, that has various notations similar to quasiquote, quasisyntax, etc. However, as I consider using these notations in macros' generated code, I notice something a lot like variable …

---

## [How ellipsis works in macro?](https://racket.discourse.group/t/how-ellipsis-works-in-macro/692)

<div class="topic-metadata">

**Author:** [@chansey97](https://racket.discourse.group/u/chansey97)\
**Replies:** 7\
**Last updated:** [February 19, 2022, 6:50am UTC](https://racket.discourse.group/t/how-ellipsis-works-in-macro/692 "2022-02-19T06:50:58Z")

</div>

The ellipsis seems to work in the most obvious way, but it is still difficult to understand for me. Below I will explain my current understanding and provide a naive translation to map, but there are quite a few examples…

---

## [A question about free-identifier=?](https://racket.discourse.group/t/a-question-about-free-identifier/685)

<div class="topic-metadata">

**Author:** [@chansey97](https://racket.discourse.group/u/chansey97)\
**Replies:** 5\
**Last updated:** [February 13, 2022, 11:28pm UTC](https://racket.discourse.group/t/a-question-about-free-identifier/685 "2022-02-13T23:28:39Z")

</div>

I am learning Racket macro. I have a question about free-identifier=?. Why the following code return #t? (free-identifier=? #'car (let (\[car 8\]) #'car)) ;; #t Does the #'car under the let access the same binding? Th…

---

## [Haskell-inspired define-where macro](https://racket.discourse.group/t/haskell-inspired-define-where-macro/672)

<div class="topic-metadata">

**Author:** [@benknoble](https://racket.discourse.group/u/benknoble)\
**Replies:** 0\
**Last updated:** [February 10, 2022, 2:21pm UTC](https://racket.discourse.group/t/haskell-inspired-define-where-macro/672 "2022-02-10T14:21:29Z")

</div>

Here's a little Haskell-inspired macro I whipped up for define: #lang racket (require (only-in racket/base \[define def\])) (require syntax/parse/define) (define-syntax-parser define \[(\_ head e:expr #:where body:expr…

---

## [What would be a "recipe" and lesson plan for building a Racket-like system?](https://racket.discourse.group/t/what-would-be-a-recipe-and-lesson-plan-for-building-a-racket-like-system/554)

<div class="topic-metadata">

**Author:** [@bmitc](https://racket.discourse.group/u/bmitc)\
**Replies:** 3\
**Last updated:** [January 12, 2022, 6:25am UTC](https://racket.discourse.group/t/what-would-be-a-recipe-and-lesson-plan-for-building-a-racket-like-system/554 "2022-01-12T06:25:58Z")

</div>

I am looking for any help, references, etc. that describes how one might take Racket's language building technology and other bits and relevant lessons learned to other languages, ecosystems, or virtual machines (VMs), e…

[Previous page](https://racket.discourse.group/tag/macro/28.md?match_all_tags=true&tags%5B%5D=macro)

[Next page](https://racket.discourse.group/tag/macro/28.md?match_all_tags=true&page=2&tags%5B%5D=macro)
