-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
execute() should return a set not a handle #2530
Comments
What about just having the pattern matcher wrap its results in a |
If we make that visible to the end-user, that's the third bullet; if we try to hide it, for backwards compat, its the second bullet. The current internal implementation is already almost that -- almost not quite, its sloppier and more scattered. But its a good idea, I'll take a look and clean up. Also - not just he pattern matcher, but "everything" - PutLink, etc. What's everything?
|
Also, when I first opened this issue, I completely forgot about Until now |
This partly resolves issues opencog#2530 and opencog#1502
Related: the
|
See also #2752 |
See also issue #2911 which wonders about the general problem, and proposes monads as a general solution. |
As far as I can tell, GSN's can return general Values, not just Handles. TODO would be a |
Closing. At this point in time, GSN's can return Values just fine, it all works. They can return Anway, here's a demo. It works:
|
Below is a partially-finished thought for a fundamental architectural change. It is motivated by the discussion seen in MOZI-AI/annotation-scheme#165 The issue was this:
A GSN is called to perform several computations. Rather than just depositing the results of those calculations in the AtomSpace, it was felt that the GSN should "return" several results. Since, by default, the GSN can only return a single Handle, the multiple results were wrapped in a ListLink. This lead to a proliferation of un-needed, pointless ListLinks in the AtomSpace.
This could be "fixed" by allowing the GSN to return a list (an ordered list) or a set (an unordered set), instead of returning a Handle. Under the covers, this suggests that the
execute()
method should return a list or set. All atomspace intrnals would have to be modified to deal with this. If some caller ofexecute()
really, really needed a single atom, then they could explicitly wrap it in a ListLink/SetLink at that time.The advantage of doing this is that there is less pollution of the AtomSpace with ListLinks, SetLinks. The end-user no longer would need to manage these. Another advantage is that the AtomSpace currently has multiple spots where ListLinks, SetLinks are implicitly unwrapped; perhaps these implicit unwrappings can be eased?
What might the actual solution look like? I see several possibilities:
execute()
to returnstd::vector<ValuePtr>
or maybestd::set<ValuePtr>
InternalUseOnlySetListValue
and return that. This way the C++ signature doesn't change. We just have to be carefully to make sure the user never sees this special value.Vertex
in the MOSES code-base. This kind of polymorphism is already a central underpinning concept in LISP and Scheme. This would make Atomese more lisp-like. :-/Both the second and the third bullets enable result-polymorphism. The main difference between the second and the third bullets above is that
InternalUseOnlySetListValue
is supposed to be hidden from the end-user, while the polymorphism ofVertex
is explicitly exposed to the user. I'm not sure I like making it explicit -- this leads to a snowball of design decisions that would turn Atomese into just another also-ran, poorly-designed dialect of LISP .. and that is not the intent...Somewhat related is issue #1502 aka "Stop using SetLink for search results!" The current working prototype there is to declare an AnchorNode to which return values are attached, as they appear. That is, the return value is really more of a future or a promise, that can be polled, or blocked on, until the results appear. This suggests a fourth idea:
execute()
to return a future/promise (or possibly return aFuturePromiseValue
) FWIW Design a Publish/Subscribe System (aka Futures) #1750 describes a publish/subscribe systemThe best answer remains cloudy; this requires more ... prototyping and experimentation.
The text was updated successfully, but these errors were encountered: