Support `module+` in Syndicate #langs. Closes #2.
Adding `#'module+` explicitly to the stop-list for local-expand stops the infinite recursion (problem 1 in the issue description). The code goes on to treat it like `#'module` and `#'module+`, namely as a non-action-producing form. Problem 2 in the issue description is interesting. I haven't done anything in particular to address the production of unbounded `X` -> `(begin X)` expansions, but it seems not currently to be a problem; and, weirdly (?), submodules in a `#lang syndicate` or `#lang syndicate/actor` module do not seem to inherit the `#%module-begin` of their container! That is, `(module+ main)`, `(module+ test)` etc. all seem to have a `racket/base` `#%module-begin`, though I've not looked very far into this. Most peculiar on this front is that if the `#,@(reverse final-forms)` precedes the `(module+ syndicate-main ...)`, and the module being processed includes, say, a `(module+ main)`, then for some reason the resulting `main` submodule *is* treated as having a `syndicate/lang` `#%module-begin` (thus causing problems as suggested in the issue description)! I *really* don't understand why that might be, and haven't spent very much time investigating after I noticed that so long as the `main`-required `syndicate-main` submodule preceded all other submodule declarations, things seemed to work out. This whole approach is still a bit dicey: for example, the following will erroneously treat `(foo quux)` as an expression yielding actions, rather than a struct declaration: #lang syndicate (define-syntax-rule (foo x) (struct x ())) (foo quux)
This commit is contained in:
parent
75cec37038
commit
b6c679afa6
|
@ -39,8 +39,7 @@
|
|||
(define (accumulate-actions action-ids final-forms forms)
|
||||
(if (null? forms)
|
||||
(let ((final-stx
|
||||
#`(#%module-begin #,@(reverse final-forms)
|
||||
(module+ syndicate-main
|
||||
#`(#%module-begin (module+ syndicate-main
|
||||
(provide boot-actions activate!)
|
||||
(define activated? #f)
|
||||
(define boot-actions (list #,@(reverse action-ids)))
|
||||
|
@ -48,6 +47,7 @@
|
|||
(when (not activated?)
|
||||
(set! activated? #t)
|
||||
boot-actions)))
|
||||
#,@(reverse final-forms)
|
||||
(module+ main
|
||||
(require (submod ".." syndicate-main))
|
||||
(run-ground (activate!))))))
|
||||
|
@ -55,7 +55,7 @@
|
|||
final-stx)
|
||||
(syntax-case (local-expand (car forms)
|
||||
'module
|
||||
(kernel-form-identifier-list)) ()
|
||||
(cons #'module+ (kernel-form-identifier-list))) ()
|
||||
[(head rest ...)
|
||||
(if (free-identifier=? #'head #'begin)
|
||||
(accumulate-actions action-ids
|
||||
|
@ -63,7 +63,7 @@
|
|||
(append (syntax->list #'(rest ...)) (cdr forms)))
|
||||
(if (ormap (lambda (i) (free-identifier=? #'head i))
|
||||
(syntax->list #'(define-values define-syntaxes begin-for-syntax
|
||||
module module*
|
||||
module module* module+
|
||||
#%module-begin
|
||||
#%require #%provide)))
|
||||
(accumulate-actions action-ids
|
||||
|
|
Loading…
Reference in New Issue