Created
April 17, 2021 23:16
-
-
Save countvajhula/42d0d3d35fbce29589bf4f9750a58138 to your computer and use it in GitHub Desktop.
Calling an unhygienic macro from another macro
This file contains 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
#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