[r6rs-discuss] A different take on libraries
On Wed, 15 Nov 2006, Abdulaziz Ghuloum wrote:
>> An implementation is further allowed to start each expansion of a
>> library form by removing all library bindings above phase 0.
>>
>> Can this be interpreted as a license to write macros that expand to
>> imports? If so you can add your own clauses. I am not 100% sure, that this
>> is allowed.
>
> The line from 6.2 can be deciphered as: "Don't rely on side effects when you
> write macros." The compiler is licensed to reload the compile-time
> information before expanding a form so any state saved from previous
> invocations of a macros may not persist to the next invocation.
If I understand you correctly, I don't think so. Are you saying compile-time
information may be reloaded before expanding any macro, or simply before
expanding a new "library" form? If the former, this is incorrect. The
specification clearly states that imports are invoked at most once (or once per
meta-level in the other semantics). As a result, you can clearly rely on state
in between macro invocations while expanding a library. This is, indeed, part
of the point of the invocation semantics, designed to make things like
record-type expand-time registries possible.
To answer Jens's question: No, macros cannot currently expand to new kinds of
"import" statements. Given the current expansion algorithm, this would only be
possible if "import" was part of the body, which it is not.
Cheers
Andre
Received on Wed Nov 15 2006 - 12:05:30 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC