Module: Ruff::Standard::DelimCtrl
- Defined in:
- lib/ruff/standard/delim_ctrl.rb
Overview
DelimCtrl
provides one-shot delimited control operators, shift
and reset
.
Class Method Summary collapse
-
.reset(&th) ⇒ Object
delimits a continuation.
-
.shift(&k) ⇒ Object
captures a continuation.
Class Method Details
.reset(&th) ⇒ Object
delimits a continuation
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruff/standard/delim_ctrl.rb', line 25 def reset(&th) eff = Ruff::Effect.new @stack.push eff ret = Ruff.handler .on(eff) do |k, f| f.call(k) end .run(&th) @stack.pop ret end |
.shift(&k) ⇒ Object
captures a continuation.
42 43 44 45 46 |
# File 'lib/ruff/standard/delim_ctrl.rb', line 42 def shift(&k) # fetch nearmost prompt top = @stack.last top.perform(k) end |