Reimplement leach so that stack is clean when executing the quotation

The previous implementation let garbage on the stack (such as the lazy list
cdr) before executing the quotation. This prevents easy implementation of
reduce-like words using leach.
db4
Samuel Tardieu 2007-12-21 05:42:25 +01:00
parent f2b4a04a44
commit 858237c0f8
1 changed files with 1 additions and 5 deletions

View File

@ -100,11 +100,7 @@ M: lazy-cons list? ( object -- bool )
dup car swap cdr ;
: leach ( list quot -- )
swap dup nil? [
2drop
] [
uncons swap pick call swap leach
] if ;
swap dup nil? [ 2drop ] [ uncons swapd over 2slip leach ] if ; inline
TUPLE: memoized-cons original car cdr nil? ;