]> gitweb.factorcode.org Git - factor.git/blob - extra/partial-continuations/partial-continuations.factor
FUEL: Fix bug whereby true display-stacks? could hang the listener.
[factor.git] / extra / partial-continuations / partial-continuations.factor
1 ! Copyright (C) 2006 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: partial-continuations
4 USING: kernel continuations arrays sequences quotations ;
5
6 : breset ( quot -- )
7     [ 1array swap keep first continue-with ] callcc1 nip ;
8
9 : (bshift) ( v r k -- obj )
10     >r dup first -rot r>
11     [
12         rot set-first
13         continue-with
14     ] callcc1
15     >r drop nip set-first r> ;
16
17 : bshift ( r quot -- )
18     swap [ ! quot r k
19         over >r
20         [ (bshift) ] 2curry swap call
21         r> first continue-with
22     ] callcc1 2nip ; inline