OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace commits / f15068f

Simplify return value of PureExecLink
f15068f83b5e9ccd2a1e4b7b862a95f2a42eb99d
by Linas Vepštas <linasvepstas@gmail.com> · 2026-01-21T21:05:08.000Z

Changed files (1) +19 -3

opencog/atoms/parallel/PureExecLink.cc +19 -3
……@@ -70,7 +70,13 @@ ValuePtr PureExecLink::execute(AtomSpace* as,
7070 if (h->is_type(ATOM_SPACE))
7171 {
7272 ctxt = AtomSpaceCast(h).get();
73 vseq.push_back(h); // Record it too, for posterity.
73 // Well, we could "record it for posterity", but if the
74 // user only wanted to do one thing and get the result,
75 // this extra labelling just gets in the way. Worse, the
76 // user would almost surely discard this label, anyway.
77 // If they really really need this info, they can get it
78 // in other ways.
79 // vseq.push_back(h); // Record it, for posterity.
7480 continue;
7581 }
7682 if (not h->is_executable())
……@@ -96,14 +102,24 @@ ValuePtr PureExecLink::execute(AtomSpace* as,
96102 // Special case. New context.
97103 if (vp->is_type(ATOM_SPACE))
98104 ctxt = AtomSpaceCast(vp).get();
99
100 vseq.emplace_back(vp);
105 else
106 vseq.emplace_back(vp);
101107
102108 // If we are using a scratch space, clear it.
103109 if (scratch.get() == ctxt)
104110 scratch->clear();
105111 }
106112
113 // Sop to the user. If only one item, return that one item.
114 // This feels both hacky, and also reasonable. The hacky
115 // feeling is that it behaves differently, based on size. Yuck.
116 // But its also natural, as why should we wrap just one thing?
117 // This would force the user to unwrap, adding complexity to
118 // processing pipelines. The user just wanted to "do just one
119 // thing", and we did it; the extra gift-wrapping is just junk.
120 if (1 == vseq.size())
121 return vseq[0];
122
107123 return createLinkValue(std::move(vseq));
108124}
109125