Open linas opened 3 years ago
At this time, building on top of QueueValue
seems the most sensible thing to do. This could be formalized by providing an API within QueuueValue itself, instead of inheriting from what's in cogutils.
The following attempt was made:
The reason that this was reverted is because it didn't seem to be needed, and there seems to be a more generic solution: if one really needs stuff stuck to an AnchoreNode, then create a new kind of Value, that dequeues from the QueueValue, as results come in, and sticks them onto an AnchoreNode. This could be done for any kind of data stream, and not just for queries.
There has been some minor exploration of how compositionality works; it is demoed in the (still existing) example query.scm This example uses AnchorNodes, but without needing pull req #2500 to do it. It "works". It's even multi-threaded, so its "naturally" parallel. Is it clunky? I dunno. It posts results to the AtomSpace, ... but why? was this really needed?
Issue #1502 "Stop using SetLink for search results!" highlights a problem with the compositionality of the search and processing primitives in Atomese. Search results were (still are) delivered wrapped in a
SetLink
. This presents challenges for the cleanup of search results, and various other core issues (See issues described on the SetLink wiki.)Basically, it is difficult to create long processing pipelines, such as
(cog-evaluate! (SequentialAnd ... (Put .... (State ... (Get ... (SequentialOr ... (Delete ... (Bind ...
with the top-levelSequentialAnd
written to be tail recursive. Such long pipelines have been implemented (in the robot code, circa 2017) and they do work (see for example the tail-recusion demo and older copies of the https://github.com/opencog/ros-behavior-scripting repo) However, there are problems:SetLink
s when they are no longer needed.PutLink
and other assorted functions (e.g.PlusLink
when given a set of numbers to add.)A replacement solution is needed. Desirable properties:
LinkStream
Value.So basically, there are two issues being explored here, in tandem:
A wholly unexplored idea:
Setlink
is as a kind of sloppy monad and thus what we really need is a cleaned-up monad to hold multiple-value results. The precise way to do this is unclearThe best idea seems to be:
FormulaStream
andFutureStream
and also withQueueValue
. Currently, there is no way to concatenateQueueValue
s.QueueValue
already multiplexes, in a way. This should be provided as an add-on to the above. (Some old, obslete ideas were discussed in issue 1750: #1750.)The following progress has been made:
The cogutils provides five thread-safe tools for building these things:
std::set
. Note it provides deduplication (just likestd::set
does.)std::set
provides, i.e. instd::less_than
order.Note that
QueueValue
is built on top ofconcurrent_queue.h
Implementing compositionality requires finishing work on the
$vau
-ization (fexpr-ization) of Atomese functions. See$vau
(aka fexper) on Wikipedia. Many or most functions now work like this; the grand exceptions include thePutLink
and most of the TruthValue subsystem.Possible building block for monads or related:
AtomSpacePtr
is now a kind ofValuePtr
. No one is using this for anything, just yet. There is no way to automatically project/collapse contents of derived atomspaces back into the main atomspace. (You'd have to do it by hand.) This could generalize: Atomspaces could be layered arbitrarily deep; passed around, hold temporary results that disappear when all references to the AtomSpace disappear. AtomSpaces could be stored in ordinary Links.QueryLink
andMeetLink
. The whole value flow subsystem is envisioned as being able to handle flows of ... values ... and not flows of atoms.To explore these issues, and possible solutions, some demos are suggested. So far, we have the following demos and related issues:
2752 -- Transient Atoms -- this describes another data flow issue.
2215 -- SatisfactionLink used to leave behind a
*-PatternGroundingKey-*
that told you how it was satisfied. But this crumbled away.