Created
March 26, 2019 22:14
-
-
Save LeifAndersen/0e625b56167bbd15a9dfd2745836ae73 to your computer and use it in GitHub Desktop.
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/load | |
(module A racket | |
(require syntax/parse/define) | |
(provide define-foo) | |
(define-syntax-parser define-foo | |
[(_ name body ...) | |
#:with this-syntax (datum->syntax #'name 'this-syntax) | |
#'(begin | |
(define-syntax foo2 | |
(syntax-parser | |
[(_ n) | |
#:do [(define this-syntax #'n)] | |
body ...])) | |
(define-syntax name | |
(syntax-parser | |
[(_) #'(foo2 name)])))])) | |
(module B racket | |
(require 'A syntax/parse/define) | |
(provide (all-defined-out)) | |
(define-syntax-parser define/leif | |
[(_) | |
#:with leif (datum->syntax this-syntax 'leif) | |
#'(define leif 42)]) | |
(define-foo blue | |
#:with leif (datum->syntax this-syntax 'leif) | |
#'leif)) | |
(module C racket | |
(require 'B) | |
(define/leif) | |
(blue)) | |
(require 'C) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment