[r6rs-discuss] Interpreters need not apply?

From: Pascal Costanza <pc>
Date: Wed Mar 7 10:06:41 2007

On 7 Mar 2007, at 15:51, AndrevanTonder wrote:

> On Wed, 7 Mar 2007, Pascal Costanza wrote:
>
>> The terms "compiler" and "interpreter" are not well-defined. But
>> AFAICT, a compiler typically works in two phases: A translation
>> from one representation to another one, where the latter is
>> typically a representation that can be executed by some
>> interpreter (for example, a CPU).
>
> No r5rs-conformant Scheme interpreter will start evaluating a form
> without macro-expanding it first. R6RS requires nothing more than
> this.

Here is an example:

(if expression form1 form2)

Assume that both form1 and form2 are macro invocations. Will form1
and form2 both be macroexpanded before the if statement is evaluated,
or will first the expression be evaluated and depending on its
outcome only either form1 or form2 be expanded and then evaluated? Is
the latter evaluation approach possible or forbidden in the current
version of R6RS?

This can be interesting, as I tried to explain, because in the first
evaluation approach, you expand one form that you strictly don't need
to expand, and it can be beneficial to avoid this.

>> Interpreters are interesting because they sometimes have better
>> performance characteristics than compilers. Especially when code
>> is loaded or generated on demand at runtime, a compilation step
>> may incur a much larger overhead than "pure" interpretation. For
>> example, this is the case when the loaded or generated code is
>> only executed once or just a few times.
>>
>> This is, BTW, one of the reasons why "modern" virtual machines,
>> like those for Java, Smalltalk or Self, are so efficient: They
>> simply defer compilation until there is enough evidence that
>> certain hotspots actually benefit from an extra compilation step.
>
> Do you consider these language specifications more interpreter-
> friendly than r6rs? If I remember correctly, all Java code has to
> be encapsulated in classes. These have to be assembled into a well-
> formed program, which is sytax-checked and typed-checked, before
> anything will run. Does r6rs mandate, in your view, a heavier
> burden than this?

What is interesting in this context is the implementation approach of
the HotSpot virtual machine for Java, or similar implementation
techniques, definitely not the language defined on top of that. Java
the language requires compilation into bytecode before execution.

I can't judge whether the burden in R6RS is heavier or not, because I
don't know the details of R6RS that well. I have just tried to give
some meaning to what "pure interpretation" could possibly mean.


Pascal

-- 
Pascal Costanza, mailto:pc_at_p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium
Received on Wed Mar 07 2007 - 10:05:53 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC