Closed vsbogd closed 11 months ago
One minor thing: Is there a reason not to change the
&dyn VariableSet
argument to a generic? This would then mean you could change the Iterator type in theVariableSet
trait into an associated type, and eliminate the box for the return type oniter()
.
Do you mean this https://github.com/trueagi-io/hyperon-experimental/pull/522/commits/ee447d168d52b39ca27d2a294573823403b075e6 ?
Exactly! :-)
Thanks Luke!
There is a code duplication in interpreter2.rs
where operation arguments are parsed twice to print stack and interpret them. I think it makes sense to eliminate this duplication but I will try doing it in a separate PR.
Filter out type errors and interpretation errors from the final result to make almost all tests green. One test still fails (this one https://github.com/trueagi-io/hyperon-experimental/blob/main/python/tests/scripts/f1_imports.metta) but it seems the reason is one of the module system improvements made recently. I would like to wait for a module system refactoring before fixing it. Most changes in PR are attempts to make code faster and simpler after making tests green.
Further plans are to make code faster and think about making minimal MeTTa semantics more clear and explaining it in the documentation.
In order to be able simpler debug the code printing a stack trace of minimal MeTTa calls is added. Stack has a structure which allows searching for the function call point and function return point in the log.
Status of the current operation is explicitly represented in the interpreter by two values
Final
andInProgress
. It allows usingchain
with any other minimal MeTTa operation andchain
uses this flag to understand whether the operation is finished and its result should be applied to the last argument ofchain
.Collapse and superpose operations are added into minimal instruction set but with unique names
collapse-bind
andsuperpose-bind
. They operate not by a expression of atoms but by expression of pairs(atom, bindings)
in order to allowsuperpose
keep tracking bindings aftercollapse
. These two instructions are used to replace the workarounds introduced before. This change made interpreter slower because of processing results ofcollapse
usingfoldl-atom
andmap-atom
implemented in MeTTa.One cosmetic change which affects some old code: I have to introduce
VariableSet
in order to allow passing bothHashSet<VariableAtom>
andHasSet<&VariableAtom>
to theBindings
's methods.