[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] library syntax: "visiting" a library left undefined?



On Fri, Jan 4, 2013 at 8:39 AM, John Cowan <cowan@x> wrote:
Aaron W. Hsu scripsit:

> 1) Evaluation of the library forms, but not the arbitrary code bodies of
> those forms, giving you information on the imports and exports of the
> library, and gives a specific code body for the following steps, based
> on the results of cond-expand;

Thanks, this is very helpful.  IIUC, I would say "examination" rather than
"evaluation" here, as cond-expanding is not really evaluation.

> 2) Visitation, which gives you definitions of the keywords in the
> library, but does not evaluate any of the code. This is akin in some
> systems to expansion; and finally,
>
> 3) Instantiation, which evaluates the code definitions and binds their
> exports, as well as evaluating the forms in the body that are found.

Okay.  I have changed the wording again to this:

    Similarly, during the expansion of a library {\cf foo}, if a syntax
    keyword imported from another library {\cf (bar)} is needed to
    expand the library, then the syntax definitions of {\cf (bar)}
    must be loaded and expanded before the expansion of {\cf (foo)}.

Loading is not necessary, as Aaron pointed out.

In our simplified situation with no low-level macros, we
really only need to expand the library, and in fact
we don't have to expand lambda bodies, so the minimum
requirement is a superficial trace of the library skeleton,
"evaluating" top-level macros.  This trace is what's generally
referred to as visiting, and may simply be expansion.

Although Aaron is correct that in the general case we
can't single out the specific macros used, it is not
impossible in all cases, and would therefore be wrong
for the standard to forbid such optimizations.

Note also the timing is unspecified.  Chicken uses a batch
compiler to separate syntax definitions from normal
definitions, and load only the syntax on import (but loads
all syntax, not restricting to just the used forms).  In
this case the visit has already been done once, in a
sense, but is not re-performed every time.  I guess a
general "before" covers this, since we say nothing of
how long before or how many times.

Assuming we don't want to add a long discussion of the
definition of visitation for something that is fairly simple
in the small language, I would suggest:

    Similarly, during the expansion of a library {\cf foo}, if
    any syntax keywords imported from another library {\cf (bar)}
    are needed to expand the library, then the corresponding syntax
    definitions of {\cf (bar)} must be expanded before the
    expansion of {\cf (foo)}.

-- 
Alex

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports