Open ARCJ137442 opened 1 month ago
The code does the right thing there, the code piece you reference searches the implication tables for a link which unifies with the users's question. But I agree this index trickery sucks and can potentially be improved at some point. :)
Also: your observation that index 0 is reserved for temporal implications without operation (which is like a do-nothing operator almost) is valid.
Background Information
I noticed that ONA has a concept of operations called "do nothing operator", which is related to NAL-8 and can be seen at:
https://github.com/opennars/OpenNARS-for-Applications/blob/96f4d032183b23c6fcef92cc4ac3947151f784a6/src/Decision.h#L87-L88
In normal code logic, the integer "operator id" corresponding to this "do nothing operator" is 0, and in many places "is do-nothing operator or not" is distinguished by
op
or!op
:https://github.com/opennars/OpenNARS-for-Applications/blob/96f4d032183b23c6fcef92cc4ac3947151f784a6/src/Cycle.c#L385-L389
Some code refers to "traversing all real operators" by explicitly traversing 1 through
OPERATIONS_MAX
:https://github.com/opennars/OpenNARS-for-Applications/blob/96f4d032183b23c6fcef92cc4ac3947151f784a6/src/Decision.c#L423
The Main Issue
The main issue happens in the following code:
https://github.com/opennars/OpenNARS-for-Applications/blob/96f4d032183b23c6fcef92cc4ac3947151f784a6/src/NAR.c#L190-L211
Notice the
int op_k = 0; op_k<OPERATIONS_MAX
in the code, which actually means "traverse the previous operator from the do-nothing operator to the last operator" when the fieldprecondition_beliefs
in structConcept
is defined to allow "do nothing operator" in index0
:https://github.com/opennars/OpenNARS-for-Applications/blob/96f4d032183b23c6fcef92cc4ac3947151f784a6/src/Concept.h#L57
So, Do we need to prohibit traversing "do nothing operator" here? Like the following:
Or do you want to allow all operations including "do nothing operator"?
(like above)
Or, Do we need to make a clear distinction between "real operators" and "do nothing operator" and "no operation id found"?