Streams Work in progress

Streams are a way of viewing strings, files, and collections. The metaphor is that of magnetic tape in a tape recorder. This tutorial presents some of the basic concepts and gives you a good feel. It should help you absorb the detail presented in the operators section. There are many operators supporting streams. However, they are made up of descriptive simple glyphs with simple meanings.

Depending on what the programmer intends to accomplish, he looks for different capabilities in streaming operators. If he is reading sequentially through a text file he is usually looking for combinations of returns and line feeds as line delimiters. If he is streaming through a binary file he may be slewing a constant number of bytes to be displayed in hexadecimal format. Or he may be looking for specific delimiters or words.

Strings and files have a number of state variables which serve streaming needs. Among these are:

Additionally he may want to find the position of the next target without reading or moving the cursor. He may want to move the cursor but not read. He may just want to work at the ends of the stream. With all these combinations of needs it is challenging to provide a suite of operators that is intuitive. To do this I have adopted a sort of hieroglyphic language. I have assigned meanings to individual glyphs and then define operators by combining these glyphs. The glyphs are:

  The fundamental Stream glyphs: Examples:
Compound
Glyphs
Meaning
Commentary `
``
@
<-
->
<<-
->>
&
|
^

?
Index of
Indices of
Seek or At
Beginning
Ending
Previous
Next
All
Any
Contains

Where (query)
str @<-
str `->
str @->>
str `->>& 'GLEE'
str <<-| ';.'
str ?`@

str ?`@<<-
str ?@<-
str ?@->
str ^& 'GLEE'
str ^| '.,;'
str ->> n
Seek Beginning of stream
Bytes in last line
Seek to next CRLF
Index of next "GLEE"
Read to previous ";" or "."
query index at
query index at previously
at start of stream?
at end of stream?
Contains "GLEE"
Contains ". , or ; "
Read next "n" bytes



Commentary Code Result