IN: delimited-continuations USING: kernel continuations namespaces locals sequences accessors fry math ; SYMBOL: Holes : hole-init ( -- ) V{ } clone Holes set ; : hole-push ( hole -- ) Holes get push ; : hole-pop ( -- hole ) Holes get pop ; : abort-top ( v -- * ) hole-pop continue-with ; : set-top ( quot -- obj ) '[ hole-push @ ] callcc1 ; inline : reset ( quot -- obj ) '[ @ abort-top ] set-top ; inline :: shift ( quot -- obj ) [| k | [| x | [ x k continue-with ] set-top ] quot call abort-top ] callcc1 ; inline