add equivalent of racket's begin-for-syntax
Created by: WreckedAvent
Context:
I want to be able to write private helpers for my macros. Currently, the only way to do this is to have another module which you import. This seems less-than-ideal to me and involves some weirdness like import ... for syntax. I suggest having a syntax block which puts all of the statements into the correct phase to be used in macros.
Example:
syntax {
let next = ctx => ctx.next().value
syntax inc = ctx => #`${next(ctx)} + 1`
}
inc 10
would compile to
10 + 1
Considerations:
- @jlongster mentioned a
forSyntaxaccepting an IIFE to achieve this instead. This seems less intuitive to me. - The
import ... for syntaxcould be implied within asyntaxblock -
syntax identifierseems kind of awkward to me inside of asyntaxblock but not sure if there's any better ways to approach it