Skip to content

Instantly share code, notes, and snippets.

@countvajhula
Created April 17, 2021 23:16
Show Gist options
  • Save countvajhula/42d0d3d35fbce29589bf4f9750a58138 to your computer and use it in GitHub Desktop.
Save countvajhula/42d0d3d35fbce29589bf4f9750a58138 to your computer and use it in GitHub Desktop.
Calling an unhygienic macro from another macro
#lang racket
(require syntax/parse
syntax/parse/define
(for-syntax racket/base))
(define-syntax (maclambda stx)
(syntax-parse stx
[(_ expr val)
(with-syntax ([x (datum->syntax stx 'x)])
#'((λ (x) expr) val))]))
(define-syntax (call-maclambda stx)
(syntax-parse stx
[(_ expr val)
#'(maclambda expr val)]))
;; this works:
(maclambda (add1 x) 5)
;; but this doesn't:
;; (call-maclambda (add1 x) 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment