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
parent
f2b4a04a44
commit
858237c0f8
|
@ -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? ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue