Skip to content

Macros generating macro applications and phases #1908

@munificent

Description

@munificent

The macro proposal allows macros to produce code which contains macro applications. When that happens, it says:

If a macro application is added which implements an earlier phase, that phase
is not ran. This should result in a warning if the macro does not also
implement some phase that will be ran.

If a macro application is added which runs in the same phase as the current
one, then it is immediately expanded after execution of the current macro,
following the normal ordering rules.

That seems both confusing and brittle to me. I can't imagine a macro author ever wanting an earlier phase of their macro to be silently skipped just because it happens to have a later phase and some other macro happened to generate the application.

My first inclination is to say we disallow generating macro applications entirely. I don't know that we have a strong use case for it. If we do have a compelling use case, I think we should consider looping the entire expansion process. Something like:

  1. Apply all phase 1 macros.
  2. Apply all phase 2 macros (that were not added in this cycle).
  3. Apply all phase 3 macros (that were not added in this cycle).
  4. If any of those produced new macro applications, then goto 1 and run all three phases of those new macro applications.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions