Hi Andres,
it is quite impressive.
On 22.1.2013 08:22, Andres Navarro wrote:
> [...]
> The idea is that after analyzing the environment in which the symbols of
> the expression are evaluated, it replaces some of them with either
> primitive combiners or direct accesses to the environment (to avoid
> looking for the correct bindings at run time). There is still no
> support for executing the resulting expression (no way in klisp to
> access the environment directly), but you can see the result (the
> symbols are marked with angle brackets for visualization (e.g. 'cons'
> becomes '<cons>' because it is a primitive applicative and 'ls' may
> become '<ls><0,1>', i.e. a direct access to the current environment for
> the first binding).
>
I may be mistaken, but is it related to alpha-conversion? Could fklisp,
with some changes, do transformations like this:
($let ((a #t)) ($let ((a ($lambda (a) a))) a))
=>
($let ((x #t)) ($let ((y ($lambda (z) z))) y))
?
> [..] All of this takes under 4
> seconds in an Intel i7 (pretty neat considering it is written in Kernel
> and running in klisp).
>
It takes about 20s on an old Pentium 4, with these definitions added:
($quote (x) #ignore x)
(vv () (eval ($quote ww) (get-current-environment)))
(ww () (eval ($quote vv) (get-current-environment)))
=>
($quote (x) #ignore <x><0.0>)
(vv () (<eval> (<$quote><1.48> <ww><1.51>) (<get-current-environment><1.32>)))
(ww () (<eval> (<$quote><1.48> <vv><1.50>) (<get-current-environment><1.32>)))
Defining mutually recursive functions, while looking under $quote. Cool.
This takes somewhat more time:
($quote (x) #ignore x)
(dl (x e) (eval (list $lambda (list $quote a) x ($quote a) ($quote b)) e))
(f (a x) (dl x (get-current-environment)))
=>
($quote (x) #ignore <x><0.0>)
(dl
(x e)
(<eval>
(<list><1.0>
<$lambda><1.33>
(<list><1.0> <$quote><1.48> a)
<x><0.0>
(<$quote><1.48> a)
(<$quote><1.48> b))
<e><0.1>))
(f (a x) (<dl><1.49> <x><0.1> (<get-current-environment><1.32>))))
Why is the symbol "a" in (list $lambda ...) not solved here?
> [..]
Oto Havle.