diff --git a/lib/src/metta/runner/stdlib.metta b/lib/src/metta/runner/stdlib.metta index 430895e01..7217e243c 100644 --- a/lib/src/metta/runner/stdlib.metta +++ b/lib/src/metta/runner/stdlib.metta @@ -50,7 +50,7 @@ (: unify (-> Atom Atom Atom Atom %Undefined%)) (= (unify $a $a $then $else) $then) (= (unify $a $b $then $else) - (case (unify-or-empty $a $b) ((%void% $else))) ) + (case (unify-or-empty $a $b) ((Empty $else))) ) (: unify-or-empty (-> Atom Atom Atom)) (= (unify-or-empty $a $a) unified) (= (unify-or-empty $a $b) (empty)) diff --git a/lib/src/metta/runner/stdlib.rs b/lib/src/metta/runner/stdlib.rs index 3b8335a8c..b10a21fb2 100644 --- a/lib/src/metta/runner/stdlib.rs +++ b/lib/src/metta/runner/stdlib.rs @@ -18,8 +18,6 @@ use regex::Regex; use super::arithmetics::*; use super::string::*; -pub const VOID_SYMBOL : Atom = sym!("%void%"); - fn unit_result() -> Result, ExecError> { Ok(vec![UNIT_ATOM()]) } @@ -1187,7 +1185,7 @@ mod non_minimal_only_stdlib { Ok(result) if result.is_empty() => { cases.into_iter() .find_map(|(pattern, template, _external_vars)| { - if pattern == VOID_SYMBOL { + if pattern == EMPTY_SYMBOL { Some(template) } else { None @@ -1864,10 +1862,10 @@ mod tests { let case_op = CaseOp::new(space.clone()); assert_eq!(case_op.execute(&mut vec![expr!(("foo")), - expr!(((n "B") n) ("%void%" "D"))]), + expr!(((n "B") n) ("Empty" "D"))]), Ok(vec![Atom::sym("A")])); assert_eq!(case_op.execute(&mut vec![expr!({MatchOp{}} {space} ("B" "C") ("C" "B")), - expr!(((n "C") n) ("%void%" "D"))]), + expr!(((n "C") n) ("Empty" "D"))]), Ok(vec![Atom::sym("D")])); } diff --git a/lib/src/metta/runner/stdlib_minimal.rs b/lib/src/metta/runner/stdlib_minimal.rs index c64af4637..08f6feb63 100644 --- a/lib/src/metta/runner/stdlib_minimal.rs +++ b/lib/src/metta/runner/stdlib_minimal.rs @@ -16,8 +16,6 @@ use std::convert::TryInto; use super::arithmetics::*; use super::string::*; -pub const VOID_SYMBOL : Atom = sym!("%void%"); - fn unit_result() -> Result, ExecError> { Ok(vec![UNIT_ATOM()]) } @@ -410,9 +408,7 @@ impl Grounded for CaseOp { log::debug!("CaseOp::execute: atom results: {:?}", results); let results = match results { Ok(results) if results.is_empty() => - // TODO: MINIMAL in minimal MeTTa we should use Empty in both - // places here and in (case ...) calls in code - vec![switch(VOID_SYMBOL)], + vec![switch(EMPTY_SYMBOL)], Ok(results) => results.into_iter().map(|atom| switch(atom)).collect(), Err(err) => vec![Atom::expr([ERROR_SYMBOL, atom.clone(), Atom::sym(err)])], @@ -633,13 +629,13 @@ mod tests { #[test] fn metta_case_empty() { - let result = run_program("!(case Empty ( (ok ok) (%void% nok) ))"); + let result = run_program("!(case Empty ( (ok ok) (Empty nok) ))"); assert_eq!(result, Ok(vec![vec![expr!("nok")]])); - let result = run_program("!(case (unify (C B) (C B) ok Empty) ( (ok ok) (%void% nok) ))"); + let result = run_program("!(case (unify (C B) (C B) ok Empty) ( (ok ok) (Empty nok) ))"); assert_eq!(result, Ok(vec![vec![expr!("ok")]])); let result = run_program("!(case (unify (B C) (C B) ok nok) ( (ok ok) (nok nok) ))"); assert_eq!(result, Ok(vec![vec![expr!("nok")]])); - let result = run_program("!(case (unify (B C) (C B) ok Empty) ( (ok ok) (%void% nok) ))"); + let result = run_program("!(case (unify (B C) (C B) ok Empty) ( (ok ok) (Empty nok) ))"); assert_eq!(result, Ok(vec![vec![expr!("nok")]])); } diff --git a/lib/tests/case.rs b/lib/tests/case.rs index 8c06219fd..02cfedf99 100644 --- a/lib/tests/case.rs +++ b/lib/tests/case.rs @@ -49,11 +49,11 @@ fn test_case_operation() { (((Rel-P $y) (P $y)) ((Rel-Q $y) (Q $y)))) - ; %void% can be used to capture empty results + ; Empty can be used to capture empty results !(case (match &self ($rel B $x) ($rel $x)) (((Rel-P $y) (P $y)) ((Rel-Q $y) (Q $y)) - (%void% no-match))) + (Empty no-match))) ; a functional example (= (maybe-inc $x)