# \[PADL'23\] Modern Macros

**URL:** <https://racket.discourse.group/t/padl23-modern-macros/1805>\
**Category:** General\
**Tags:** macro\
**Created:** [March 12, 2023, 6:46pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805 "2023-03-12T18:46:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [March 12, 2023, 6:46pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/1 "2023-03-12T18:46:12Z")

</div>

[PADL'23] Modern Macros

Keynote by Robby Findler

[![](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/0/01f6bd7ceca01cc11f9e4f4142bd1c91c7bac90e.jpeg "[PADL'23] Modern Macros") ](https://www.youtube.com/watch?v=YMUCpx6vhZM)

[https://youtu.be/YMUCpx6vhZM](https://youtu.be/YMUCpx6vhZM)

> **[Modern Macros (PADL 2023 - : The 25th International Symposium on Practical...](https://popl23.sigplan.org/details/PADL-2023-papers/20/Modern-Macros)**
>
> Declarative languages comprise several well-established classes of formalisms, namely, functional, logic, and constraint programming. Such formalisms enjoy both sound theoretical bases and the availability of attractive frameworks for application...

Description:

#### **Modern Macros**

[Racket](https://www.racket-lang.org/)’s approach to macros is the latest point in an evolution that started in 1963 with Lisp’s macros. Building on those ideas, Racket’s macros have evolved so far that, to a modern macro programmer, macros are more helpfully understood as extending and manipulating the compiler’s front end than as a mechanism for textual substitution or syntactic abstraction.

Having a malleable compiler front end naturally enables succinct implementations of many domain-specific and embedded languages. A look at the Racket ecosystem reveals a wealth of examples. [Scribble](https://docs.racket-lang.org/scribble/), a language for writing texts uses a LaTeX-inspired syntax and has been used to write thousands of pages of documentation, dozens of research papers, and at least two books. [Redex](https://redex.racket-lang.org/), a language for writing and testing operational semantics, has helped numerous researchers debug their semantics and explore their ideas. Racket’s sister-language, [Typed Racket](https://docs.racket-lang.org/ts-guide/), boasts numerous type-level innovations and full-fledged interoperability with untyped code. Beside these large efforts, Racket’s macros also have enabled extensions on the medium scale as well, being the basis for its pattern matcher, class system, contract system, family of `for` loops, and more. On the small scale, project-specific macros are common in Racket codebases, as Racket programmers can lift the language of discourse from general programming-language constructs to project-specific concerns, aiding program comprehension and shrinking codebase size.

In this talk, I’ll discuss the essential aspects of Racket’s macro system design, showing how they enable [language-oriented programming](https://felleisen.org/matthias/manifesto/) and provide an intellectual foundation for understanding modern macros. These aspects all center on the idea of automatically managing scope and taking advantage of its automatic management.

Going beyond implementing languages, the data structures supporting automatic scope management have proven central to DrRacket (the Racket IDE), specifically its rename refactoring and its ability to navigate code-bases via uses and definitions of identifiers. Recently, Racketeers have begun to explore how more aspects of Racket’s macro system can support sophisticated IDE tooling for programming languages in the Racket ecosystem. I will try to paint a picture of where we hope to go with that work as well.

source code repo for the talk [GitHub - rfindler/modern-macros-talk](https://github.com/rfindler/modern-macros-talk/)

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [March 13, 2023, 12:42am UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/2 "2023-03-13T00:42:50Z")

</div>

If anyone is interested in the papers referenced at the beginning of the talk:

_Eugene Kohlbecker, Daniel P. Friedman, Matthias Felleisen, and Bruce Duba. 1986. Hygienic macro expansion. In Proceedings of the 1986 ACM conference on LISP and functional programming (LFP '86). Association for Computing Machinery, New York, NY, USA, 151–161._ [_https://doi.org/10.1145/319838.319859_](https://doi.org/10.1145/319838.319859)

_William Clinger and Jonathan Rees. 1991. Macros that work. In Proceedings of the 18th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL '91). Association for Computing Machinery, New York, NY, USA, 155–162._ [_https://doi.org/10.1145/99583.99607_](https://doi.org/10.1145/99583.99607)

_R. Kent Dybvig, Robert Hieb, and Carl Bruggeman. 1992. Syntactic abstraction in Scheme. Lisp Symb. Comput. 5, 4 (Dec. 1992), 295–326._ [_https://doi.org/10.1007/BF01806308_](https://doi.org/10.1007/BF01806308)

_Matthew Flatt. 2002. Composable and compilable macros: you want it when? In Proceedings of the seventh ACM SIGPLAN international conference on Functional programming (ICFP '02). Association for Computing Machinery, New York, NY, USA, 72–83. [https://doi.org/10.1145/581478.581486](https://doi.org/10.1145/581478.581486)_

_Matthew Flatt. 2002. Composable and compilable macros: you want it when? SIGPLAN Not. 37, 9 (September 2002), 72–83._ [_https://doi.org/10.1145/583852.581486_](https://doi.org/10.1145/583852.581486)

_Matthew Flatt. 2016. Binding as sets of scopes. SIGPLAN Not. 51, 1 (January 2016), 705–717. [https://doi.org/10.1145/2914770.2837620](https://doi.org/10.1145/2914770.2837620)_

_Matthew Flatt. 2016. Binding as sets of scopes. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '16). Association for Computing Machinery, New York, NY, USA, 705–717. [https://doi.org/10.1145/2837614.2837620](https://doi.org/10.1145/2837614.2837620)_

* * *

May also be of interest:

_William D. Clinger and Mitchell Wand. 2020. Hygienic macro technology. Proc. ACM Program. Lang. 4, HOPL, Article 80 (June 2020), 110 pages. [https://doi.org/10.1145/3386330](https://doi.org/10.1145/3386330)_

And video: [PLDI 2021: Hygienic Macro Technology](https://www.pldi21.org/prerecorded_hopl.13.html)

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [March 13, 2023, 4:40am UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/3 "2023-03-13T04:40:47Z")

</div>

Thanks for posting this! Nicely done. That audience was right on the borderline between inquisitive and irritating... I'm thinking I may show this in class tomorrow.

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [March 13, 2023, 9:54am UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/4 "2023-03-13T09:54:17Z")

</div>

It would be interesting to hear how your students respond.

I couldn’t really hear the questions, which was a shame. I’m hoping I’ll have better luck with headphones or maybe the questions were captured in the transcript.

S.

---

<div class="post-metadata">

**Author:** ![robby](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/robby/32/7_2.png) [@robby](https://racket.discourse.group/u/robby)\
**Post date:** [March 13, 2023, 2:52pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/5 "2023-03-13T14:52:18Z")

</div>

Thanks for posting this and finding the citations and DOIs. I've added that to the README.md in the [source code repo for the talk](https://github.com/rfindler/modern-macros-talk/).

---

<div class="post-metadata">

**Author:** ![Laurent.O](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/laurent.o/32/18_2.png) [@Laurent.O](https://racket.discourse.group/u/Laurent.O)\
**Post date:** [March 15, 2023, 1:54pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/6 "2023-03-15T13:54:38Z")

</div>

Was the talk recorded by any chance?

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [March 15, 2023, 2:06pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/7 "2023-03-15T14:06:13Z")

</div>

Yes!

[https://youtu.be/YMUCpx6vhZM](https://youtu.be/YMUCpx6vhZM)

Best regards

Stephen :beetle:

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [March 17, 2023, 1:31am UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/8 "2023-03-17T01:31:55Z")

</div>

Oh! Super happy to hear about the source code for the slides, I will 100% use this (with credit) the next time I present macros.

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [March 20, 2023, 6:09pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/9 "2023-03-20T18:09:08Z")

</div>

Someone on lobster.rs reminded me that @robby [mentioned a paper](https://youtu.be/YMUCpx6vhZM?t=1324) - did they get the right paper?

> Around 22:06 he mentions “sometimes you want to be able to temporarily change what the IR is”, and that there’s a nice paper about it. It must be this: [Macros for Domain-Specific Languages](https://par.nsf.gov/servlets/purl/10220787).

---

<div class="post-metadata">

**Author:** ![shhyou](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@shhyou](https://racket.discourse.group/u/shhyou)\
**Post date:** [March 20, 2023, 6:24pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/10 "2023-03-20T18:24:32Z")

</div>

I suppose that's the one and also [https://docs.racket-lang.org/ee-lib/index.html](https://docs.racket-lang.org/ee-lib/index.html)

---

<div class="post-metadata">

**Author:** ![notjack](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@notjack](https://racket.discourse.group/u/notjack)\
**Post date:** [March 27, 2023, 11:38pm UTC](https://racket.discourse.group/t/padl23-modern-macros/1805/11 "2023-03-27T23:38:12Z")

</div>

Sounds like the talk was building up to mentioning Resyntax-related tooling at the very end there 👀
