clean up initialization of the teachpacks in an empty repl
In more detail, the way the initial namespace was being set up was different than the way that you get if you just hit 'Run' on an empty program. So change the initial namespace creation to more closely mimic the way an running an empty program works.
This commit is contained in:
parent
a57e712ba3
commit
23d5cf568e
|
@ -468,8 +468,12 @@
|
||||||
(newline port)))
|
(newline port)))
|
||||||
|
|
||||||
(define/override (first-opened settings)
|
(define/override (first-opened settings)
|
||||||
(for ([tp (in-list (htdp-lang-settings-teachpacks settings))])
|
(define-values (mod name)
|
||||||
(namespace-require/constant tp)))
|
(create-empty-module (get-module)
|
||||||
|
(htdp-lang-settings-teachpacks settings)))
|
||||||
|
(eval mod)
|
||||||
|
(dynamic-require `',name #f)
|
||||||
|
(current-namespace (module->namespace `',name)))
|
||||||
|
|
||||||
(define/private (tp-require->str tp)
|
(define/private (tp-require->str tp)
|
||||||
(match tp
|
(match tp
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
(only-in racket/sequence sequence->list))
|
(only-in racket/sequence sequence->list))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
|
[create-empty-module (->* (any/c (listof any/c)) (symbol?) (values any/c symbol?))]
|
||||||
[expand-teaching-program (->* (input-port?
|
[expand-teaching-program (->* (input-port?
|
||||||
(-> any/c input-port? any/c)
|
(-> any/c input-port? any/c)
|
||||||
any/c
|
any/c
|
||||||
|
@ -27,6 +28,15 @@
|
||||||
;; a require. The module includes a 'require' for each teachpack that
|
;; a require. The module includes a 'require' for each teachpack that
|
||||||
;; the user has added. Also, any 'provide' expressions are stripped out.
|
;; the user has added. Also, any 'provide' expressions are stripped out.
|
||||||
|
|
||||||
|
(define (create-empty-module language-module teachpacks [module-name '#%htdp])
|
||||||
|
(values (datum->syntax
|
||||||
|
#f
|
||||||
|
`(,#'module ,module-name ,language-module
|
||||||
|
,@(map (λ (x)
|
||||||
|
`(require ,x))
|
||||||
|
teachpacks)))
|
||||||
|
module-name))
|
||||||
|
|
||||||
(define (expand-teaching-program port reader language-module teachpacks [module-name '#%htdp] [enable-testing? #t])
|
(define (expand-teaching-program port reader language-module teachpacks [module-name '#%htdp] [enable-testing? #t])
|
||||||
(define state 'init)
|
(define state 'init)
|
||||||
;; state : 'init => 'require => 'done-or-exn
|
;; state : 'init => 'require => 'done-or-exn
|
||||||
|
@ -43,12 +53,7 @@
|
||||||
(λ (x)
|
(λ (x)
|
||||||
(set! saved-exn x)
|
(set! saved-exn x)
|
||||||
(expand
|
(expand
|
||||||
(datum->syntax
|
(create-empty-module language-module teachpacks module-name)))])
|
||||||
#f
|
|
||||||
`(,#'module ,module-name ,language-module
|
|
||||||
,@(map (λ (x)
|
|
||||||
`(require ,x))
|
|
||||||
teachpacks)))))])
|
|
||||||
(define body-exps (suck-all-exps port reader))
|
(define body-exps (suck-all-exps port reader))
|
||||||
(define teachpack-requires (teachpacks->requires teachpacks))
|
(define teachpack-requires (teachpacks->requires teachpacks))
|
||||||
(rewrite-module
|
(rewrite-module
|
||||||
|
|
Loading…
Reference in New Issue
Block a user