Last active
July 23, 2018 17:43
-
-
Save LeifAndersen/d35d386ddb1a1b25d7b22d97ab6287e8 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 scratch | |
(provide x) | |
(define x 42) |
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 scratch | |
(require "moddef.rkt") | |
(define ns (make-base-empty-namespace)) | |
(define modpath (make-resolved-module-path (resolve-module-path "moddef.rkt"))) | |
(parameterize ([current-namespace ns] | |
[current-module-declare-name modpath]) | |
(eval #'(module dummy racket/base | |
(define x 'dummy) | |
(provide x))) | |
(namespace-require modpath)) | |
(define the-x (namespace-syntax-introduce (datum->syntax #f 'x) ns)) | |
(eval the-x) |
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/define | |
"moddef.rkt" | |
(for-syntax syntax/modresolve)) | |
(define-syntax-parser conv-ident | |
[(_ mod sym) | |
(define mp (make-resolved-module-path (resolve-module-path (syntax->datum #'mod)))) | |
(define s (syntax->datum #'sym)) | |
(define ns (make-base-empty-namespace)) | |
(parameterize ([current-namespace ns] | |
[current-module-declare-name mp]) | |
(eval #'(module dummy racket/base | |
(define s 'dummy) | |
(provide s))) | |
(namespace-require mp)) | |
(namespace-syntax-introduce (datum->syntax #f (syntax->datum #'sym)))]) | |
(conv-ident "moddef.rkt" x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment