let task_args: Vec = vec![]; let mut block = func.call(&mut context, task_args); let ignored = Value::Boolean(bool::default()); let mut state = block.resume_with(ignored); loop { match &state { GeneratorState::Yielded(FunctionInterruption::Effect { name, args }) => { // try to handle side effect if unknown_side_effect { // print debug information return Err(RuntimeError::EffectNotImplemented); } else { let effect_return_value = { /* ... */ }; state = block.resume_with(effect_return_value); } }, GeneratorState::Yielded(FunctionInterruption::Exception(exc)) => { // print exception return Err(RuntimeError::UncaughtException); }, GeneratorState::Complete(val) => { // type check function's return value break; } } }