-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Some macros, and specifically the mod macro in the Module/Functor system @iitalics and I are working on, should do all the elaboration passes themselves, and they should not be part of the elaboration passes of the outer module. Given this, they should call local-expand+elaborate to set up those passes. However, when submodules of an outer module expand, they are already within an elaboration pass, so the call to local-expand+elaborate errors out.
Should there be a call-with-no-elaborate-pass function or an extra argument to local-expand+elaborate so that macros like this can reset the elaborator and start a new set of passes?
Using the call-with-no-elaborate-pass function would look like this:
(call-with-no-elaborate-pass
(λ ()
(local-expand+elaborate ...expr...))))Or using some kind of extra argument might look like this:
(local-expand+elaborate ...expr... #:reset? #true)An implementation of call-with-no-elaborate-pass might look like:
(define (call-with-no-elaborate-pass f)
(parameterize ([current-syntax-elaborate-pass #f]
[current-elaborate-did-make-progress? #f]
[current-elaborate-did-defer? #f]
[current-elaborate-defer-id #f])
(f)))Or an implementation of the #:reset? argument might look like:
(define (local-expand+elaborate stx #:reset? [reset? #f] [intdef-ctxs '()])
....
(when (and (current-syntax-elaborate-pass) (not reset?))
(raise-arguments-error 'local-expand+elaborate "already elaborating"))
....)