x = '0' function start () return function () end end function set_x (v) x = v return function () end end function if_x (v) if x == v then print ("x = ", v) return function (block) block[1]() end else print ("x != ", v) return function () end end end -- DSL here start { set_x '10', if_x '10' { function() print ('x is 10') end }, if_x '20' { function() print ('x is 20') end } }