OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-sensory commits / bcc9f4a

Get rid of PromiseLink
bcc9f4a57b006af57c8efab14e93b727af77854a
by Linas Vepštas <linasvepstas@gmail.com> · 2025-10-28T01:18:08.000Z

Changed files (3) +8 -8

examples/file-write.scm +4 -4
……@@ -138,12 +138,12 @@
138138; We don't want to do just one line: we want to process the entire
139139; stream, until end-of-file. For that, create a promise to do that,
140140; when executed.
141(define prom
142 (Promise (TypeNode 'FutureStream) rule-applier))
141(define promise
142 (CollectionOf (TypeNode 'FutureStream) (OrderedLink rule-applier)))
143143
144144; Designate the promise as the source of data for the file writer.
145145(cog-execute!
146 (SetValue (Concept "source") (Predicate "key") prom))
146 (SetValue (Concept "source") (Predicate "key") promise))
147147
148148; Run the file-writer. This uses exactly the same definition as before.
149149; Be sure to `ls -la /tmp/foobar.txt` before and after running this,
……@@ -161,7 +161,7 @@
161161
162162; If unclear about the promise, you can explore it several ways.
163163; One is to do this: (Be sure to reset the input file, first.)
164; (cog-value->list (cog-execute! prom))
164; (cog-value->list (cog-execute! promise))
165165; This will process one line at a time.
166166;
167167; Equivalently, use ValueOf to get the value:
examples/irc-echo-bot.scm +2 -2
……@@ -325,13 +325,13 @@
325325; But we don't want a one-a-a-time interface; we want this to run
326326; indefinitely. For that, we need a promise, that can pull items
327327; through the filter. (The filter itself cannot push.)
328; The PromiseLink can pull items through the Filter. So wrap the
328; The FutureStream can pull items through the Filter. So wrap the
329329; filter in that. When this is attached to the file writer, it
330330; will run forever. The infinite loop doing this is located in
331331; StreamNode::write() method.
332332(define logger
333333 (SetValue irc-log-file (Predicate "*-write-*")
334 (Promise (TypeNode 'FutureStream) format-for-logger)))
334 (CollectionOf (TypeNode 'FutureStream) (OrderedLink format-for-logger))))
335335
336336; Run the logger in it's own thread.
337337(cog-execute! (ExecuteThreaded logger))
examples/parse-pipeline.scm +2 -2
……@@ -94,8 +94,8 @@
9494; many layers, so the LinkSignature puts one layer back.
9595(define linker
9696 (LinkSignature (Type 'LinkValue)
97 (PromiseLink (Type 'FlatStream)
98 parse-stream)))
97 (CollectionOfLink (Type 'FlatStream)
98 (OrderedLink parse-stream))))
9999
100100; Sniff test. Does it work?
101101; (cog-execute! linker)