trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
141 stars 47 forks source link

API for Grounded Atom Types should be capable of returning multiple atoms #346

Open luketpeterson opened 1 year ago

luketpeterson commented 1 year ago

Currently the Rust GroundedAtom trait has the following method function:

fn type_(&self) -> Atom;

However, in conversations it sounds like we actually want to be capable of returning a set of atoms for the type.

Additionally, the Rust interface allows a grounded atom to implement a function to return the type atom(s). It's unclear to me if this is because Rust doesn't support storage associated with abstract interfaces, or whether we want to provide different grounded atoms backed by the same implementation the ability to assert different types. This flexibility seems useful to me.

If atom-specific dynamic typing function is intended, then the C & Python APIs should also support this functionality.

vsbogd commented 1 year ago

Issue is correct in a sense that we should have method to assign non-deterministic types to grounded atoms as well.

There is a plan to try alternative implementation of grounded functions in which grounded functions are called via equality expressions. In such case types of the grounded grounded functions can be added into space in the same manner as they are added for the pure functions. Thus I would postpone resolving this issue until we try the alternative implementation. For grounded values it can still be valid though.