# \#macro

**URL:** https://racket.discourse.group/tag/macro/28.md

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

---

## [Alternatives to scope sets for hygiene?](https://racket.discourse.group/t/alternatives-to-scope-sets-for-hygiene/4377)

<div class="topic-metadata">

**Author:** [@jgarvin](https://racket.discourse.group/u/jgarvin)\
**Replies:** 1\
**Last updated:** [September 7, 2026, 9:59pm UTC](https://racket.discourse.group/t/alternatives-to-scope-sets-for-hygiene/4377 "2026-09-07T21:59:33Z")

</div>

My understanding is that Racket hygiene being based on scope sets was chosen in part for historical reasons; e.g. the scope pruning scheme was added to be backwards compatible with existing idioms. I've skimmed the docs…

---

## [Macro that expands to (module .. (provide (all-defined-out)) ..)](https://racket.discourse.group/t/macro-that-expands-to-module-provide-all-defined-out/4270)

<div class="topic-metadata">

**Author:** [@wluker](https://racket.discourse.group/u/wluker)\
**Replies:** 10\
**Last updated:** [June 1, 2026, 2:30pm UTC](https://racket.discourse.group/t/macro-that-expands-to-module-provide-all-defined-out/4270 "2026-06-01T14:30:21Z")

</div>

I'm attempting to create a macro that expands to a submodule, but I can't seem to figure out how to use the (provide (all-defined-out)) form indroduced by the macro. Here is an example: #lang racket/base (module defpkg…

---

## [How to achieve zero-overhead type dispatch in macros (similar to C++ templates)?](https://racket.discourse.group/t/how-to-achieve-zero-overhead-type-dispatch-in-macros-similar-to-c-templates/4070)

<div class="topic-metadata">

**Author:** [@litjohn](https://racket.discourse.group/u/litjohn)\
**Replies:** 8\
**Last updated:** [January 1, 2026, 7:27pm UTC](https://racket.discourse.group/t/how-to-achieve-zero-overhead-type-dispatch-in-macros-similar-to-c-templates/4070 "2026-01-01T19:27:44Z")

</div>

Hi everyone! This is my first post here. I've been exploring Racket macros and have a question regarding performance and types. Is there a way in Racket to achieve zero-overhead type dispatch similar to C++ templates? …

---

## [How to debug macros?](https://racket.discourse.group/t/how-to-debug-macros/4027)

<div class="topic-metadata">

**Author:** [@hendrikboom3](https://racket.discourse.group/u/hendrikboom3)\
**Replies:** 4\
**Last updated:** [November 27, 2025, 7:06pm UTC](https://racket.discourse.group/t/how-to-debug-macros/4027 "2025-11-27T19:06:21Z")

</div>

I get this message: . . ../../../../../usr/local/racket/collects/racket/private/kw.rkt:1263:25: application: not a procedure; expected a procedure that can be applied to arguments given: #\<void\> It suggests to me th…

---

## [What's the deal with \`X . op . Y\`?](https://racket.discourse.group/t/whats-the-deal-with-x-op-y/3400)

<div class="topic-metadata">

**Author:** [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Replies:** 13\
**Last updated:** [November 4, 2025, 10:18pm UTC](https://racket.discourse.group/t/whats-the-deal-with-x-op-y/3400 "2025-11-04T22:18:03Z")

</div>

Hi, Racket Discourse. I have some free time this morning, so I thought I'd ask your opinion on using the "infix" form of application, namely (f x y) -\> (x . f . y), and maybe waste your time enjoyably. Personally, I am…

---

## [‘3D syntax’ explanation](https://racket.discourse.group/t/3d-syntax-explanation/3995)

<div class="topic-metadata">

**Author:** [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Replies:** 0\
**Last updated:** [November 4, 2025, 8:58am UTC](https://racket.discourse.group/t/3d-syntax-explanation/3995 "2025-11-04T08:58:05Z")

</div>

Hi ‘3D syntax’ came up in the discord recently and Jade Sailor kindly provided an explanation and example: 3d syntax is when a syntax object is programmatically constructed to contain something which doesn't have a…

---

## [Gathering macro-time information](https://racket.discourse.group/t/gathering-macro-time-information/3981)

<div class="topic-metadata">

**Author:** [@hendrikboom3](https://racket.discourse.group/u/hendrikboom3)\
**Replies:** 2\
**Last updated:** [October 25, 2025, 3:58am UTC](https://racket.discourse.group/t/gathering-macro-time-information/3981 "2025-10-25T03:58:26Z")

</div>

Context: Now I am implementing in Racket a few of the control structures of Ink, a notation for writing text adventure games. (If you are interested, see Writing web-based interactive fiction with ink ) I have the fol…

---

## [Providing name only to sub-module?](https://racket.discourse.group/t/providing-name-only-to-sub-module/3918)

<div class="topic-metadata">

**Author:** [@pcn](https://racket.discourse.group/u/pcn)\
**Replies:** 11\
**Last updated:** [October 12, 2025, 12:06am UTC](https://racket.discourse.group/t/providing-name-only-to-sub-module/3918 "2025-10-12T00:06:45Z")

</div>

Context: Inspired by Lean's #guard commands, I'd like to implement "static unit tests" in Racket, where tests give the same interactive feedback as types. An example would look something like below: (define (factorial …

---

## [Resolving/expanding syntax object in context of specific module](https://racket.discourse.group/t/resolving-expanding-syntax-object-in-context-of-specific-module/3954)

<div class="topic-metadata">

**Author:** [@kimmyg](https://racket.discourse.group/u/kimmyg)\
**Replies:** 2\
**Last updated:** [September 23, 2025, 1:31am UTC](https://racket.discourse.group/t/resolving-expanding-syntax-object-in-context-of-specific-module/3954 "2025-09-23T01:31:24Z")

</div>

I am defining a macro in a rhombus module that produces legal shplait syntax and is intended to be accessed by a module written in shplait. What is the most direct and/or preferred way to associate the shplait language …

---

## [Macro expansion: evaluating a pattern variable that could be a number or a function](https://racket.discourse.group/t/macro-expansion-evaluating-a-pattern-variable-that-could-be-a-number-or-a-function/3862)

<div class="topic-metadata">

**Author:** [@ddrake](https://racket.discourse.group/u/ddrake)\
**Replies:** 14\
**Last updated:** [July 24, 2025, 7:36pm UTC](https://racket.discourse.group/t/macro-expansion-evaluating-a-pattern-variable-that-could-be-a-number-or-a-function/3862 "2025-07-24T19:36:10Z")

</div>

This is related to my struggles with getting a new #lang to work. I've discovered a bug in my code, but I am not sure how to modify my macro to make it work as expected. The key parts of my macro and supporting code are…

---

## [High-level explanation of how the expander's event stream is structured](https://racket.discourse.group/t/high-level-explanation-of-how-the-expanders-event-stream-is-structured/3821)

<div class="topic-metadata">

**Author:** [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Replies:** 0\
**Last updated:** [June 27, 2025, 11:26pm UTC](https://racket.discourse.group/t/high-level-explanation-of-how-the-expanders-event-stream-is-structured/3821 "2025-06-27T23:26:42Z")

</div>

@notjack @mflatt @ryanc I'm attempting to give Resyntax more and better information from the macro expander, and to do so I'm taking a closer look at a lot of the log-expand events emitted by the expander. I'm aware of…

---

## [\`~describe\` vs. \`#:role\` in \`syntax-parse\`](https://racket.discourse.group/t/describe-vs-role-in-syntax-parse/3795)

<div class="topic-metadata">

**Author:** [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Replies:** 4\
**Last updated:** [June 21, 2025, 2:45am UTC](https://racket.discourse.group/t/describe-vs-role-in-syntax-parse/3795 "2025-06-21T02:45:30Z")

</div>

How should we choose between ~describe descriptions and #:role for error information with syntax-parse? Consider this macro, inspired by a discussion on Discord: #lang racket (require (for-syntax syntax/parse)) (defi…

---

## [How to attach an exception to a syntactic location?](https://racket.discourse.group/t/how-to-attach-an-exception-to-a-syntactic-location/3631)

<div class="topic-metadata">

**Author:** [@ToddOBryan](https://racket.discourse.group/u/ToddOBryan)\
**Replies:** 0\
**Last updated:** [March 16, 2025, 4:50pm UTC](https://racket.discourse.group/t/how-to-attach-an-exception-to-a-syntactic-location/3631 "2025-03-16T16:50:35Z")

</div>

Following along with Beautiful Racket, I'm trying to implement the AP Computer Science Principles pseudo-code that is used on the exam. So far, so good. Except that I'd like to have errors attach to the locations in t…

---

## [DSLs for Safe iOS/watchOS Communication](https://racket.discourse.group/t/dsls-for-safe-ios-watchos-communication/3570)

<div class="topic-metadata">

**Author:** [@bogdan](https://racket.discourse.group/u/bogdan)\
**Replies:** 2\
**Last updated:** [February 19, 2025, 6:22am UTC](https://racket.discourse.group/t/dsls-for-safe-ios-watchos-communication/3570 "2025-02-19T06:22:53Z")

</div>

Just sharing a post I wrote today on enhancing a Swift project by leveraging a Racket DSL. https://defn.io/2025/02/16/type-safe-watchos-communication/

---

## [Macro expander/Module system - build-module-name](https://racket.discourse.group/t/macro-expander-module-system-build-module-name/3559)

<div class="topic-metadata">

**Author:** [@mendelsshop](https://racket.discourse.group/u/mendelsshop)\
**Replies:** 1\
**Last updated:** [February 16, 2025, 3:27pm UTC](https://racket.discourse.group/t/macro-expander-module-system-build-module-name/3559 "2025-02-16T15:27:59Z")

</div>

I am implementing a macro expander for a language I am writing. I was looking at https://github.com/mflatt/expander (in the demi branch), in module-path.rkt. There is a function build-module-name: ;; Build a submodule …

---

## [One Kind of Binding?](https://racket.discourse.group/t/one-kind-of-binding/3414)

<div class="topic-metadata">

**Author:** [@countvajhula](https://racket.discourse.group/u/countvajhula)\
**Replies:** 29\
**Last updated:** [February 7, 2025, 1:55pm UTC](https://racket.discourse.group/t/one-kind-of-binding/3414 "2025-02-07T13:55:37Z")

</div>

Hello, This is a topic that's come up from time to time in Qi meetings. I'm moving it out into a separate thread so that others can follow and chime in. It'd be nice to understand: Could we have the same macro system w…

---

## [URL-builder macro](https://racket.discourse.group/t/url-builder-macro/3476)

<div class="topic-metadata">

**Author:** [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Replies:** 7\
**Last updated:** [January 11, 2025, 10:38pm UTC](https://racket.discourse.group/t/url-builder-macro/3476 "2025-01-11T22:38:44Z")

</div>

Hi, Racket Discourse. I have been tinkering with this idea for the past couple of weeks, because I realized I was abstracting the URLs of API endpoints at the wrong level in my HTTP requests library, which made it hard …

---

## [How to Require Macros from Untyped Racket in Typed Racket with Dependencies on Typed Imports?](https://racket.discourse.group/t/how-to-require-macros-from-untyped-racket-in-typed-racket-with-dependencies-on-typed-imports/3349)

<div class="topic-metadata">

**Author:** [@NoahStoryM](https://racket.discourse.group/u/NoahStoryM)\
**Replies:** 1\
**Last updated:** [November 25, 2024, 6:13pm UTC](https://racket.discourse.group/t/how-to-require-macros-from-untyped-racket-in-typed-racket-with-dependencies-on-typed-imports/3349 "2024-11-25T18:13:58Z")

</div>

How to Require Macros from Untyped Racket in Typed Racket with Dependencies on Typed Imports? I'm facing an issue when trying to require a macro defined in an untyped Racket module into a Typed Racket module. The macro …

---

## [In macro, is object a macro or a procedure?](https://racket.discourse.group/t/in-macro-is-object-a-macro-or-a-procedure/3323)

<div class="topic-metadata">

**Author:** [@Laurent.O](https://racket.discourse.group/u/Laurent.O)\
**Replies:** 11\
**Last updated:** [November 22, 2024, 3:40pm UTC](https://racket.discourse.group/t/in-macro-is-object-a-macro-or-a-procedure/3323 "2024-11-22T15:40:19Z")

</div>

Hi all, In the following example, a syntax error is raised because of (apply op args) can't work when op is a macro like and. How can I force the macro to go through the second branch when apply doesn't apply? #lang r…

---

## [Origin of the term “phase”](https://racket.discourse.group/t/origin-of-the-term-phase/3287)

<div class="topic-metadata">

**Author:** [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Replies:** 6\
**Last updated:** [November 4, 2024, 7:22am UTC](https://racket.discourse.group/t/origin-of-the-term-phase/3287 "2024-11-04T07:22:18Z")

</div>

Did “Composable and Compilable Macros: You Want it When?” coin the term “phase”? The term is introduced in the first subsection of the introduction: The conventional solution is to decorate "loadP.scm" and similar fil…

---

## [Let's make sense of macro\*-generated \`define-runtime-path\`](https://racket.discourse.group/t/lets-make-sense-of-macro-generated-define-runtime-path/3279)

<div class="topic-metadata">

**Author:** [@benknoble](https://racket.discourse.group/u/benknoble)\
**Replies:** 0\
**Last updated:** [October 29, 2024, 5:55pm UTC](https://racket.discourse.group/t/lets-make-sense-of-macro-generated-define-runtime-path/3279 "2024-10-29T17:55:46Z")

</div>

This is one for the macrology experts—I'm hoping to cement my understanding of this behavior beyond "it works and I don't need to touch it" because I may indeed need to modify it some day! PS On "macro\*-generated" in th…

---

## [Graphing a syntax classes](https://racket.discourse.group/t/graphing-a-syntax-classes/2213)

<div class="topic-metadata">

**Author:** [@corpix](https://racket.discourse.group/u/corpix)\
**Replies:** 2\
**Last updated:** [October 21, 2024, 10:13am UTC](https://racket.discourse.group/t/graphing-a-syntax-classes/2213 "2024-10-21T10:13:58Z")

</div>

Hey, Racket community! I am writing a DSL for ClickHouse database and made some amount of syntax classes already. After some amount I feel it becomes difficult to hold everything in my head, so I have started to look is…

---

## [Racket macro: cond/define](https://racket.discourse.group/t/racket-macro-cond-define/3053)

<div class="topic-metadata">

**Author:** [@cadence](https://racket.discourse.group/u/cadence)\
**Replies:** 6\
**Last updated:** [August 1, 2024, 7:16pm UTC](https://racket.discourse.group/t/racket-macro-cond-define/3053 "2024-08-01T19:16:04Z")

</div>

I wrote a macro and wrote a blog post about it: Racket macro: cond/define - cadence's weblog (personal blog) Here's the macro: (define-syntax (cond/define stx) (syntax-parse stx ;; terminating with else \[(\_ …

---

## [Single-use macros](https://racket.discourse.group/t/single-use-macros/3022)

<div class="topic-metadata">

**Author:** [@qnc](https://racket.discourse.group/u/qnc)\
**Replies:** 3\
**Last updated:** [July 13, 2024, 1:18pm UTC](https://racket.discourse.group/t/single-use-macros/3022 "2024-07-13T13:18:01Z")

</div>

In addition to code-reuse, macros also come in handy for ad-hoc templating. I often have to repeat the following pattern: (define-syntax (xxx stx) #\`(... #,@(for/list ...) ...) xxx and never use xxx again. …

---

## [Why isn't my macro hygienic?](https://racket.discourse.group/t/why-isnt-my-macro-hygienic/2881)

<div class="topic-metadata">

**Author:** [@xiaoyu2006](https://racket.discourse.group/u/xiaoyu2006)\
**Replies:** 8\
**Last updated:** [April 24, 2024, 2:15pm UTC](https://racket.discourse.group/t/why-isnt-my-macro-hygienic/2881 "2024-04-24T14:15:43Z")

</div>

Sorry for my newbie metaprogramming question. Say I have this macro: #lang racket/base (require (for-syntax racket/base)) ;; Depends on map, eval, quote (define-syntax (eval-emit stx) (syntax-case stx () \[(\_ exp…

---

## [Some basic questions about macros and scope](https://racket.discourse.group/t/some-basic-questions-about-macros-and-scope/2731)

<div class="topic-metadata">

**Author:** [@neteroster](https://racket.discourse.group/u/neteroster)\
**Replies:** 3\
**Last updated:** [February 22, 2024, 11:31am UTC](https://racket.discourse.group/t/some-basic-questions-about-macros-and-scope/2731 "2024-02-22T11:31:32Z")

</div>

Recently, I have been reading Fear of Macros to understand some basic usage of macros in Racket. I found everything relatively easy to understand until I encountered the content related to lexical context. If my underst…

---

## [Was there a bug embedding srcloc's in compiled code in BC 8.5 (that was resolved in roughly 8.9)?](https://racket.discourse.group/t/was-there-a-bug-embedding-srclocs-in-compiled-code-in-bc-8-5-that-was-resolved-in-roughly-8-9/2647)

<div class="topic-metadata">

**Author:** [@benknoble](https://racket.discourse.group/u/benknoble)\
**Replies:** 0\
**Last updated:** [January 5, 2024, 6:53pm UTC](https://racket.discourse.group/t/was-there-a-bug-embedding-srclocs-in-compiled-code-in-bc-8-5-that-was-resolved-in-roughly-8-9/2647 "2024-01-05T18:53:42Z")

</div>

Working on some Qi things, we noticed the following error in BC 8.5: Fix marshalling issue · drym-org/qi@c09b926 · GitHub raco setup: error: during making for \<pkgs\>/qi-test/tests raco setup: write: cannot marshal val…

---

## [Optional Scribble Sections; General Macro for Inclusion / Exclusion of Code](https://racket.discourse.group/t/optional-scribble-sections-general-macro-for-inclusion-exclusion-of-code/2329)

<div class="topic-metadata">

**Author:** [@bakgatviooldoos](https://racket.discourse.group/u/bakgatviooldoos)\
**Replies:** 6\
**Last updated:** [December 14, 2023, 7:57am UTC](https://racket.discourse.group/t/optional-scribble-sections-general-macro-for-inclusion-exclusion-of-code/2329 "2023-12-14T07:57:14Z")

</div>

Hi, Racket Discourse. I am wondering whether there is an "obvious" way to include or exclude certain pieces of code based on some form of "check". In particular, I want to exclude and include certain sections in a Scrib…

---

## [Macro stepper and macros with endless recursion](https://racket.discourse.group/t/macro-stepper-and-macros-with-endless-recursion/2564)

<div class="topic-metadata">

**Author:** [@ceving](https://racket.discourse.group/u/ceving)\
**Replies:** 1\
**Last updated:** [December 1, 2023, 2:28pm UTC](https://racket.discourse.group/t/macro-stepper-and-macros-with-endless-recursion/2564 "2023-12-01T14:28:37Z")

</div>

Is it possible to step through macros with endless recursions in order to realize where the endless recursion occurs?

---

## [Error: no pattern variables before ellipsis in template](https://racket.discourse.group/t/error-no-pattern-variables-before-ellipsis-in-template/2520)

<div class="topic-metadata">

**Author:** [@ceving](https://racket.discourse.group/u/ceving)\
**Replies:** 3\
**Last updated:** [November 20, 2023, 4:05pm UTC](https://racket.discourse.group/t/error-no-pattern-variables-before-ellipsis-in-template/2520 "2023-11-20T16:05:42Z")

</div>

The following code throws the error: no pattern variables before ellipsis in template I do not understand why ::f\* is no pattern variable. Can anybody explain? #lang racket (define undefined (when #f #f)) (define …

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