Closed vsbogd closed 5 months ago
Separate custom matched grounded atoms and grounded atoms matched by equality to address https://github.com/trueagi-io/hyperon-experimental/pull/698/files#r1623809472
We cannot understand whether custom matching is implemented on a grounded atom because of lack of the specialization feature in stable Rust, so I compared two approaches:
fn Grounded::get_match(&self) -> Option<Box<dyn Fn(&Atom) -> MatchResultsIter>>
fn Grounded::as_match(&self) -> Option<&dyn CustomMatch>
Grounded::has_custom_matching
I chosen last one because:
get_match
I like this approach finally and I think we could reuse it to implement Hash on value-like grounded atoms and to move execute into a separate trait.
Hash
execute
Despite change is big most interesting files are:
lib/src/atom/mod.rs
lib/src/common/shared.rs
c/src/atom.rs
Other files contains removed default match_by_equality logic and rearranging custom matching logic to match new API.
match_by_equality
@Adam-Vandervorst FYI (cannot add you as a reviewer).
Separate custom matched grounded atoms and grounded atoms matched by equality to address https://github.com/trueagi-io/hyperon-experimental/pull/698/files#r1623809472
We cannot understand whether custom matching is implemented on a grounded atom because of lack of the specialization feature in stable Rust, so I compared two approaches:
fn Grounded::get_match(&self) -> Option<Box<dyn Fn(&Atom) -> MatchResultsIter>>
fn Grounded::as_match(&self) -> Option<&dyn CustomMatch>
Grounded::has_custom_matching
I chosen last one because:
get_match
requires additional boxing and looks more surprising than implementing a traitI like this approach finally and I think we could reuse it to implement
Hash
on value-like grounded atoms and to moveexecute
into a separate trait.Despite change is big most interesting files are:
lib/src/atom/mod.rs
lib/src/common/shared.rs
c/src/atom.rs
Other files contains removed default
match_by_equality
logic and rearranging custom matching logic to match new API.@Adam-Vandervorst FYI (cannot add you as a reviewer).