Skip to content

Commit

Permalink
Merge pull request #684 from luketpeterson/main
Browse files Browse the repository at this point in the history
`include` op to return results from evaluated sub-script
  • Loading branch information
luketpeterson authored May 6, 2024
2 parents 67d9c78 + 7037d60 commit 8b00b42
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/src/metta/runner/stdlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ impl Grounded for IncludeOp {
let program_text = String::from_utf8(program_buf)
.map_err(|e| e.to_string())?;
let parser = crate::metta::text::OwnedSExprParser::new(program_text);
//QUESTION: do we want to do anything with the result from the `include` operation?
let _eval_result = context.run_inline(|context| {
let eval_result = context.run_inline(|context| {
context.push_parser(Box::new(parser));
Ok(())
})?;

unit_result()
//NOTE: Current behavior returns the result of the last sub-eval to match the old
// `import!` before before module isolation. However that means the results prior to
// the last are dropped. I don't know how to fix this or if it's even wrong, but it's
// different from the way "eval-type" APIs work when called from host code, e.g. Rust
Ok(eval_result.into_iter().last().unwrap_or_else(|| vec![]))
}

fn match_(&self, other: &Atom) -> MatchResultIter {
Expand Down

0 comments on commit 8b00b42

Please sign in to comment.