[<<][staapl][>>][..]

Wed May 13 23:34:51 CEST 2009

## when is eager matching not working?

It would be interesting to find cases where the eager partial
evaluation scheme breaks down. One clear case is the interleaving of
orthogonal cases.
I.e. 1
dup @ 101 !
2 +
102 !
This will not evaluate "1 2 +" to "3" because the "1" is not visible
at "2 +" because of the machine code generated by "dup @ 101 !".
The proper way to solve this is to perform the following rewritings:
1 dup @ 101 ! 2 + 102 !
1 1 @ 101 ! 2 + 102 ! ; evaluate 'dup' ->
1 @ 101 ! 1 2 + 102 ! ; commute '1' and '1 @ 101 !' ->
1 @ 101 ! 3 102 ! ; evaluate '1 2 +'
Let's evaluate this using lazy macros
()
1 -> ([mw (1)])
dup -> ([mw (1)] [mw (1)])
@ -> ([mw (1)] [mw (1 @)])
101 -> ([mw (1)] [mw (1 @)] [mw (101)])
! -> ([mw (1)] [mw (1 @ 101 !)])
Now, at this point the two macros need to swap, so (2 + 102 !) can
combine with [mw (1)].
Basicly, (1 @ 101 !) should be annotated as being independent of run
time stack, and so can be tucked away.
Wait. This "tucking away" is similar to the self-removing abstractions
in Luke's idea.
The real problem here is side-effects.. I'm still comparing apples
and oranges..

[Reply][About]

[<<][staapl][>>][..]