You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NextLink is an idea to alter the pattern matcher to return one result at a time, rather than waiting for it to find all results. It is meant to replace the cog-bind-first-n scheme function. It should work something like this:
NextLink
anchor-atom
PatternLink
Here, PatternLink might be GetLink or BindLink or DualLink - any of the pattern matching links. The anchor-atom can be any atom, it will be used to distinguish different pattern searches running in parallel. (Its not obvious that the anchor is needed, so maybe it should be optional?)
Each time NextLink is called, another result atom is returned. If there are no results, then simple (Atom) is returned, to denote the empty result.
A reasonable implementation would be to cause the PatternLink to run in a distinct thread. The purpose of this thread is not to speed up or parallelize, but simply to make it easier to manage the internal state of the pattern matcher. That is, the NextLink is a de-facto continuation, and continuations need to store state somewhere. For this particular case, it seems easiest to store the pattern matcher state in a distinct thread.
Bonus points: since NextLink is essentially a "call with current continuation" (or call/cc) it might be usable with other link types, e.g. PutLink or with FilterLink or with MapLink, all of which accept sets as input and return sets as output. That is, NextLink could be used to iterate over the elements of a set. Whether or not this is a good idea is unclear; the bonus-points are to clarify this.
The text was updated successfully, but these errors were encountered:
See also #1645 "Parallelize the pattern matcher" for discussion of what a scatter-gather/map-reduce type API might be appropriate for pattern matching.
The NextLink is an idea to alter the pattern matcher to return one result at a time, rather than waiting for it to find all results. It is meant to replace the
cog-bind-first-n
scheme function. It should work something like this:Here,
PatternLink
might beGetLink
orBindLink
orDualLink
- any of the pattern matching links. The anchor-atom can be any atom, it will be used to distinguish different pattern searches running in parallel. (Its not obvious that the anchor is needed, so maybe it should be optional?)Each time
NextLink
is called, another result atom is returned. If there are no results, then simple(Atom)
is returned, to denote the empty result.A reasonable implementation would be to cause the
PatternLink
to run in a distinct thread. The purpose of this thread is not to speed up or parallelize, but simply to make it easier to manage the internal state of the pattern matcher. That is, theNextLink
is a de-facto continuation, and continuations need to store state somewhere. For this particular case, it seems easiest to store the pattern matcher state in a distinct thread.Bonus points: since
NextLink
is essentially a "call with current continuation" (or call/cc) it might be usable with other link types, e.g.PutLink
or withFilterLink
or withMapLink
, all of which accept sets as input and return sets as output. That is, NextLink could be used to iterate over the elements of a set. Whether or not this is a good idea is unclear; the bonus-points are to clarify this.The text was updated successfully, but these errors were encountered: