Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Trouble with state and module-begin
#lang racket/load
(module st racket
(define is-typed? (box #f))
(define type-env (box 0))
(provide is-typed? type-env))
(module mac racket
(require (for-syntax 'st))
(define-syntax (m stx)
(unless (> (unbox type-env) 0)
(displayln ">> type-env is 0")
(error 'fail))
(provide m))
(module lang racket
(require (for-syntax 'st))
(provide (rename-out [mb #%module-begin])
(except-out (all-from-out racket) #%module-begin))
(define-syntax (mb stx)
(displayln ">> in module-begin")
(set-box! is-typed? #t)
(syntax-case stx ()
[(_ forms ...)
forms ...
(when (unbox is-typed?)
(set-box! type-env 1))))])))
(module A1 'lang
(require (for-syntax 'st))
(require 'mac)
(module+ sub
(require 'A1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment