Skip to content

Instantly share code, notes, and snippets.

@aparatext
Created July 16, 2025 13:07
Show Gist options
  • Select an option

  • Save aparatext/3aa5c4aa625757e0b60f3b182a508c9d to your computer and use it in GitHub Desktop.

Select an option

Save aparatext/3aa5c4aa625757e0b60f3b182a508c9d to your computer and use it in GitHub Desktop.
Rust-like debug macro for Scheme
# 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