[r6rs-discuss] Question about "expand time" vs. "execution time"
Brian C. Barnes
bcbarnes at austin.rr.com
Sun May 27 21:07:30 EDT 2007
As you may have guessed by my recent flood of questions, I've pretty much
finished up my interpreter for 5.93 (except for syntax-case), and I'm now
going back and looking at all the things I left as "TODO" items. Among them
is the concept of "expansion time" vs. "execution time", and how that
relates to syntax-rules and libraries.
It seems that there is really no way to expand a macro until it is about to
be executed. Particularly in the face of being able to pass arbitrary
functions around. Consider, for example:
((_ var) var)
((_ var1 var2) (+ var1 var2))))
(display (n 5))(newline)
(display (n 5 2))(newline)))
In this case, when "bProc" is parsed, there is no indication what the
procedure "n" is going to be. It is not possible to expand the macro "ttf"
into bProc until it actually tries to execute. It is during execution that
the interpreter knows that "n" is an application of the macro ttf, and can
then expand it into place in the appropriate form. Also, it can't be
expanded by the application "(bProc ttf)", because we are simply passing it
as an argument, and don't know how (or even if) it is going to be applied.
Given this, I see no alternative but to wait until execution time, and then
expand the macro when it is being applied in the various "display" forms
shown above. This being true, what is the usefulness of "expand time" versus
"execution time" that is specified in the "for" clause of the library import
specification? If macros can't be expanded at "expand time" then what is
"expand time" meant for? If macros are to be expanded at "expand time" can
someone give me a hint how you would do this when you don't know, as in the
case above, that a macro is even being referenced, or in which form?
Brian C. Barnes
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the r6rs-discuss