Eliminate the eval hack for top-level structs

This eliminates a hack used to make the `struct` form
work at the TR top-level. The trampolining top-level
typechecker makes this unnecessary.
This commit is contained in:
Asumu Takikawa 2015-08-12 20:53:50 -04:00
parent d85a267c42
commit 2e97280335

View File

@ -135,23 +135,7 @@
(dtsi* (vars.vars ...) nm (fs.form ...)
#:maker #,cname
#,@mutable?))])
(if (eq? (syntax-local-context) 'top-level)
;; Use `eval` at top-level to avoid an unbound id error
;; from dtsi trying to look at the d-s bindings.
#'(begin (eval (quote-syntax d-s))
;; It is important here that the object under the
;; eval is a quasiquoted literal in order
;; for #%top-interaction to get the lexical
;; information for TR's actual #%top-interaction.
;; This effectively lets us invoke the type-checker
;; dynamically.
;;
;; The quote-syntax is also important because we want
;; the `dtsi` to have the lexical information from
;; this module. This ensures that the `dtsi` macro
;; is actually bound to its definition above.
(eval `(#%top-interaction . ,(quote-syntax dtsi))))
#'(begin d-s dtsi))))]))
#'(begin d-s dtsi)))]))
(lambda (stx)
(syntax-parse stx
[(_ vars:maybe-type-vars nm:struct-name/new (fs:fld-spec ...)
@ -166,11 +150,7 @@
nm.old-spec (fs.form ...)
#,@mutable?
#,@prefab?))])
;; see comment above
(if (eq? (syntax-local-context) 'top-level)
#'(begin (eval (quote-syntax d-s))
(eval `(#%top-interaction . ,(quote-syntax dtsi))))
#'(begin d-s dtsi))))]))))
#'(begin d-s dtsi)))]))))
;; this has to live here because it's used below