[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: memoizing interpreter
From: |
Neil Jerram |
Subject: |
Re: memoizing interpreter |
Date: |
Sat, 31 Dec 2005 13:27:27 +0000 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Leonardo Lopes Pereira <address@hidden> writes:
> I read that guile is a "memoizing interpreter", what that means?
It means that when Guile evaluates a source code expression for the
first time, it changes ("memoizes") some parts of the expression so
that they will be quicker to evaluate when that expression is
evaluated again.
For example, in an expression like (display x), the identifiers
`display' and `x' refer to variables somewhere in the evaluation
environment. The first time Guile evaluates (display x), it:
- locates the innermost slots in the environment with these
identifiers
- modifies the expression to something like (<shortcut to slot for
display> <shortcut to slot for x>) -- this is the memoization part
- uses the current values in those slots to complete the evaluation.
The next time Guile evaluates the same expression, the procedure is
quicker because it already has the shortcuts, so it just
- uses the current values in those slots to complete the evaluation.
This isn't the whole story of memoization. Special forms like lambda,
define and let are more drastically modified to make them easier for
subsequent evaluations. But I hope this explains the general idea.
Regards,
Neil