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

Re: [Scheme-reports] General comments on the draft WG1 R7 report.



Jay Reynolds Freeman scripsit:

> In the latter kind of implementation, many of the compile-time/
> run-time distinctions that John mentions do not exist, in the sense
> that *everything* happens within a run-time environment.

I wasn't really distinguishing between run time and compile time, but
between run time and "before run time".  The latter is the domain
of macro expansion in R5RS, but in R6-R7RS it is also the domain of
modules.  As Aaron says, things get more complicated when there is a
low-level macro facility available.  In a pure syntax-rules environment,
however, no user-written code executes until run time; only pattern
matching is done.

It sounds like your system interleaves macro expansion with execution:
when you see that a symbol in function position is a syntax keyword that
is not primitive, you invoke a macro expander to determine on the spot
what code to evaluate, and evaluate it.  You must, however, be careful
to keep an environment around that was built when the macro was defined,
in order to maintain hygiene.

For systems like that, there is indeed no need to distinguish between
run time and expansion time.  However, most Schemes pre-expand all
macros.  This is the case even for Chibi, which is intended as a small
embedded Scheme interpreter.  It is easier to expand all macros in each
definition as entered, appropriately using the define-time environment,
than to keep around first-class environments.  This is quite orthogonal
to the question of compiled output or saved worlds:  Chibi has neither,
though it expands macros and compiles the resulting "core Scheme" code
to bytecode, which is then executed by a small virtual machine.

My reference to "compiling setters and getters" in the section on
records can be reinterpreted in a non-compiling implementation as
"making setters and getters invoke unsafe underlying set and get
operations".

> Thus if I understand things correctly, for example, in a stand-alone
> interpreter there is no real benefit to using "cond-expand" as opposed
> to straight "cond" with "memv" and a list of features.  I do see that
> "cond-expand" makes good sense with separate compilation.

Quite so, reading "interleaving interpreter" for "stand-alone
interpreter".  By providing separate expand-time and run-time
facilities, we handle every case from interleaving interpretation
(Wraith, SCM) to pre-expanding all macros and interpreting (Chibi, the
Chicken interpreter) to full compilation.

> Furthermore -- though I will have to think a good deal more to be
> certain -- it looks as if the obvious way to have a stand-alone Scheme
> interpreter handle modules is to expect the user to load the files
> that contain module definitions, and implement "module" as syntax that
> creates some kind of a functional object that responds appropriately
> to "import" with the various <import set>s.

Even if you don't pre-expand macros, you may wish to pre-expand modules.
It's not necessary to use the same strategy in all parts of the system.

> I have rather the feeling that a good deal of the WG1 R7 report was 
> written with separate compilation in mind;                          

In mind, in the sense that we didn't provide things that only
interleaving interpreters can handle, but not *assuming* separate
compilation, or even whole-program compilation.

> Out of curiosity, does anyone have any idea as to what proportion
> of currently-available Scheme implementations are stand-alone
> interpreters?

Of the 30 or so open-source and portable Schemes I track, only SCM is interleaving.  

> http://web.mac.com/Jay_Reynolds_Freeman

(Do you know that there's a sequel to _The Enemy Stars_ called "The Ways
of Love"?  It appeared in _Explorations_, or if you don't have that,
there's a crappy PDF at http://tinyurl.com/3l4thyb with the story on
pp. 43-54.  It begins "Ten of their years before, we had seen that being
come through the transporter into our ship and die. This day we stood
waiting upon his world, and as we waited, we remembered.")

-- 
How they ever reached any  conclusion at all    <cowan@x>
is starkly unknowable to the human mind.        http://www.ccil.org/~cowan
        --"Backstage Lensman", Randall Garrett

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