OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace commits / 0665216

Localize IncrementValue, also
0665216152ff9bdf001e20eb475ba8dd63b91d33
by Linas Vepštas <linasvepstas@gmail.com> · 2026-01-23T21:53:32.000Z

Changed files (2) +18 -2

opencog/atoms/flow/IncrementValueLink.cc +15 -2
……@@ -46,6 +46,19 @@ IncrementValueLink::IncrementValueLink(const HandleSeq&& oset, Type t)
4646
4747// ---------------------------------------------------------------
4848
49// IncrementValue must work in the local AtomSpace. This includes
50// the evaluation of keys, as needed.
51Handle IncrementValueLink::localize(AtomSpace* as, bool silent, const Handle& h) const
52{
53 if (not h->is_executable())
54 return as->add_atom(h);
55
56 ValuePtr pap(h->execute(as, silent));
57 if (pap and pap->is_atom())
58 return as->add_atom(HandleCast(pap));
59 return h;
60}
61
4962/// When executed, this will execute the third argument to obtain
5063/// a FloatValue or NumberNode, and then use those numbers to atomically
5164/// increment the FloatValue at the indicated key on the indicated
……@@ -67,8 +80,8 @@ ValuePtr IncrementValueLink::execute(AtomSpace* as, bool silent)
6780 "Expecting AtomSpace, got null pointer for %s\n",
6881 to_string().c_str());
6982
70 Handle ah(as->add_atom(_outgoing[0]));
71 Handle ak(as->add_atom(_outgoing[1]));
83 Handle ah(localize(as, silent, _outgoing[0]));
84 Handle ak(localize(as, silent, _outgoing[1]));
7285
7386 // Copy-on-write semantics means as->increment_count() might return
7487 // a different Atom than the current ah.
opencog/atoms/flow/IncrementValueLink.h +3 -0
……@@ -38,6 +38,9 @@ namespace opencog
3838///
3939class IncrementValueLink : public FunctionLink
4040{
41protected:
42 Handle localize(AtomSpace*, bool, const Handle&) const;
43
4144public:
4245 IncrementValueLink(const HandleSeq&&, Type=INCREMENT_VALUE_LINK);
4346