Skip to content

Instantly share code, notes, and snippets.

@samth
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samth/e7b55fcef66da9b8416a to your computer and use it in GitHub Desktop.
Save samth/e7b55fcef66da9b8416a to your computer and use it in GitHub Desktop.
#lang racket
(module evaluator racket
;; Allow evaluation at phase1
(require (for-syntax racket/base syntax/parse))
(provide phase1-phase0-eval phase1-phase0-run)
(define-namespace-anchor anchor)
(define namespace (namespace-anchor->empty-namespace anchor))
(define-syntax phase1-phase0-run
(syntax-parser
[(_ form:expr ...)
#'(let-syntax ([go (lambda (stx) form ...)]) (go))]))
(define-syntax phase1-phase0-eval
(syntax-parser
[(_ form:expr ...)
#'(eval-syntax (quote-syntax (phase1-phase0-run form ...)) namespace)])))
(module f racket
(require (submod ".." evaluator))
(provide f)
(define (f) (phase1-phase0-eval (display "hello") #'#f)))
(define ns (make-base-namespace))
(current-namespace ns)
(require syntax/location)
(define name (quote-module-path f))
;(dynamic-require name 0)
((dynamic-require name 'f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment