Created
September 23, 2022 16:15
-
-
Save linkdd/7233c319fe3f2048b3b6b472459fcf0d to your computer and use it in GitHub Desktop.
Letlang basic structure of a block of code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let task_args: Vec<Value> = 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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment