Created
July 16, 2025 13:07
-
-
Save aparatext/3aa5c4aa625757e0b60f3b182a508c9d to your computer and use it in GitHub Desktop.
Rust-like debug macro for Scheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Racket | |
| (define-syntax (dbg! stx) | |
| (syntax-case stx () | |
| [(_ expr) | |
| (with-syntax ([expr-str (format "~a" (syntax->datum #'expr))]) | |
| #'(let ([result expr]) | |
| (begin | |
| (printf "~a = ~a\n" expr-str result) | |
| result)))])) | |
| # Guile | |
| (define-syntax-rule (dbg! form) | |
| (let ((result form)) | |
| (begin | |
| (format #t "~a = ~a~%" 'form result) | |
| result))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment