# Macro stepper and macros with endless recursion

**URL:** https://racket.discourse.group/t/macro-stepper-and-macros-with-endless-recursion/2564
**Category:** Questions & Answers
**Tags:** macro
**Created:** [December 1, 2023, 12:50pm UTC](https://racket.discourse.group/t/macro-stepper-and-macros-with-endless-recursion/2564 "2023-12-01T12:50:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ceving](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@ceving](https://racket.discourse.group/u/ceving)
#### Post date: [December 1, 2023, 12:50pm UTC](https://racket.discourse.group/t/macro-stepper-and-macros-with-endless-recursion/2564/1 "2023-12-01T12:50:13Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ceving](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@ceving](https://racket.discourse.group/u/ceving)
#### Post date: [December 1, 2023, 2:28pm UTC](https://racket.discourse.group/t/macro-stepper-and-macros-with-endless-recursion/2564/2 "2023-12-01T14:28:37Z")

</div>

Found another way.

```scheme
(define (write-expansion-with-limit n expr)
  (when (> n 0)
    (let ((expr (syntax->datum (expand-once expr))))
      (write expr)
      (newline)
      (write-expansion-with-limit (- n 1) expr))))

(define-syntax @
  (syntax-rules ()
    ((_ n expr)
     (write-expansion-with-limit n 'expr))))

```
