Skip to content

Allow a macro to "reset" the elaborator and do all the elaboration passes within itself #87

@AlexKnauth

Description

@AlexKnauth

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"))
  ....)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions