Re: How hard is a portable macroexpand only for display purposes? Lassi Kortela 04 Oct 2019 14:13 UTC

> Even if hygiene things and lexical scoping are neglected in the output, one
> cannot neglect them for the input of such a hypothetical "macroexpand" or
> "macroexpand-1". So either "macroexpand" has to be a special form (that is
> able to capture the lexical context, in which to do the expansion) or the
> argument to "macroexpand" already has to be a syntax object that is
> enriched with lexical information.
Can it cause unforeseen problems if macroexpand is a special form? I
can't think of any obvious problem with that, apart from the judgment
call that it's nice for everything to be a procedure whenever possible.

R7RS `eval` takes an environment-specifier argument. But is the lexical
environment in which procedures are evaluated different from the
syntactic environment in which macros are expanded?

What's the usual environment when expanding macros from the REPL -- is
it different somehow from (interaction-environment)?

Similar to `eval`, would a second argument defaulting to
(interaction-environment) work for macros or is it a lot more
complicated than that?