| … | … | @@ -138,12 +138,12 @@ |
| 138 | 138 | ; We don't want to do just one line: we want to process the entire |
| 139 | 139 | ; stream, until end-of-file. For that, create a promise to do that, |
| 140 | 140 | ; when executed. |
| 141 | (define prom | |
| 142 | (Promise (TypeNode 'FutureStream) rule-applier)) | |
| 141 | (define promise | |
| 142 | (CollectionOf (TypeNode 'FutureStream) (OrderedLink rule-applier))) | |
| 143 | 143 | |
| 144 | 144 | ; Designate the promise as the source of data for the file writer. |
| 145 | 145 | (cog-execute! |
| 146 | (SetValue (Concept "source") (Predicate "key") prom)) | |
| 146 | (SetValue (Concept "source") (Predicate "key") promise)) | |
| 147 | 147 | |
| 148 | 148 | ; Run the file-writer. This uses exactly the same definition as before. |
| 149 | 149 | ; Be sure to `ls -la /tmp/foobar.txt` before and after running this, |
| … | … | @@ -161,7 +161,7 @@ |
| 161 | 161 | |
| 162 | 162 | ; If unclear about the promise, you can explore it several ways. |
| 163 | 163 | ; 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)) | |
| 165 | 165 | ; This will process one line at a time. |
| 166 | 166 | ; |
| 167 | 167 | ; Equivalently, use ValueOf to get the value: |
| … | … | @@ -325,13 +325,13 @@ |
| 325 | 325 | ; But we don't want a one-a-a-time interface; we want this to run |
| 326 | 326 | ; indefinitely. For that, we need a promise, that can pull items |
| 327 | 327 | ; 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 | |
| 329 | 329 | ; filter in that. When this is attached to the file writer, it |
| 330 | 330 | ; will run forever. The infinite loop doing this is located in |
| 331 | 331 | ; StreamNode::write() method. |
| 332 | 332 | (define logger |
| 333 | 333 | (SetValue irc-log-file (Predicate "*-write-*") |
| 334 | (Promise (TypeNode 'FutureStream) format-for-logger))) | |
| 334 | (CollectionOf (TypeNode 'FutureStream) (OrderedLink format-for-logger)))) | |
| 335 | 335 | |
| 336 | 336 | ; Run the logger in it's own thread. |
| 337 | 337 | (cog-execute! (ExecuteThreaded logger)) |
| … | … | @@ -94,8 +94,8 @@ |
| 94 | 94 | ; many layers, so the LinkSignature puts one layer back. |
| 95 | 95 | (define linker |
| 96 | 96 | (LinkSignature (Type 'LinkValue) |
| 97 | (PromiseLink (Type 'FlatStream) | |
| 98 | parse-stream))) | |
| 97 | (CollectionOfLink (Type 'FlatStream) | |
| 98 | (OrderedLink parse-stream)))) | |
| 99 | 99 | |
| 100 | 100 | ; Sniff test. Does it work? |
| 101 | 101 | ; (cog-execute! linker) |