When a Stream is created, it is
assigned a unique Cardinal n.
Stream[n] is this StreamObject's ElicitationForm.
Reckon[streamObject] reads the current Stream element.
Stream[Noop] indicates there is no element.
Noop[Stream[n]] destroys Stream[n].
Stream[]
matches every Cardinal
number assigned to a Stream.
StreamObjects have fields:
Stream[n][Type] is the DataType of Stream[n]'s elements.
Stream[n][Slot] gives the current position of Stream[n].
Stream[n][Type[Cardinal]] returns the byte-size of Stream[n]'s current element.
Stream[n][Name]
returns the originating StreamNameSource
String (if it exists).
Stream[Name]["sourceObject"] attempts to access the external "sourceObject".
A StreamNameSource
is accessed with a Function
named the Stream[Name[Function]].
Slot[slotSpec][streamObject]
returns the Stream sub component specified by slotSpec.
Streams can be joined serially or in parallel...
And[...streamObject...] joins the streamObject(s) in ordered Sequence, (end to end).
Or[...streamObject...] joins the streamObject(s) in parallel.
Compile[Stream[n]]["fileName"] writes Stream[n] to "fileName".
Also see English definition of "stream".
In this document, "Stream" is used as a prefix or as a suffix referencing a class of objects, or processes involving StreamObjects.
StreamSources:
Stream[Name]["sourceObject"]
Stream[Name[Function]]["sourceObject"] invokes external source access.
StreamNoop
ReckonStream
NoopStream
Stream[n][FieldName]
...where FieldName is Type, Slot, Type[Cardinal], or Name returns Stream[n]'s
DataType, StreamPosition,
ElementSize,
or SourceNameString
respectively.
Slot[slotSpec][Stream[n]] (...Slotting Streams...)
Compile[Stream[n],
"sourceDepot"]...writing Stream[n]
into "sourceDepot".
The Stream
is an object
presumed to contain a finite number of elements that can be reckoned
(read) one at a time. A Stream
must be formally created, reckoned,
and destroyed. An active Stream, (StreamObject),
has various fields and a current element.
When a Stream is invoked, (as in (1) or (4) below), it may fail and return an error message (NoopNamedError) which will have the form:
Noop[Stream[...]][...]
If a StreamObject,
strm, is successfully created, it is
assigned a unique identifying Cardinal. Subsequently, Reckon[strm]
returns the current Stream element.
Any attempt to read beyond the last Stream
element returns Stream[Noop]. For details on reading Streams, see ReckonStream.
Noop[strm] attempts to destroy strm. If strm is destroyed, the unique, identifying Cardinal of the destroyed StreamObject is returned. If something prevents strm from being destroyed, an appropriate NoopNamedError (Noop[Stream[...]][...]) will be returned instead. See NoopStream.
- The creation of a StreamObject
should be confirmed (usually, in the invoking process).
- Unless a Stream's length is known in advance, each reckoned element must be compared to Stream[Noop] to detect Stream's end.
- Destruction of the StreamObject
should be confirmed by the invoking process.
A StreamSource
is anything that provides the sequential elements in a StreamObject.
If streamSource
is a List,
Set,
or String,
then...
(1)
Stream[streamSource]
...creates a StreamObject
uniquely identified by a Cardinal n and returned in
the following form:
(2)
Stream[n]
The above form (2) is key to
access Stream fields
and values. All StreamObject
elicitations involve "Stream[n]" as the identifying
subExpression.
StreamObjects
can also be "created" from external sources. When files are opened,
they are accessed through Streams.
(3)
Stream[]
...matches every Cardinal number assigned to a Stream.
In other words, if n
is the Cardinal
assigned to a Stream, then Stream[][n]
is True.
Not all Streams
are constructed with a List, Set, or String,
such as in (1).
Some Streams are accessed from external named sources. These StreamObjects are accessed from:
- file systems, or the
- Internet, or
- otherwise
(as mediated by Stream[Name[Function]]).
If "sourceObject"
is a StringName
identifying a StreamSource, then...
(4)
Stream[Name]["sourceObject"]
...attempts to create a StreamObject
from "sourceObject". If Stream[n]
is a new StreamObject, then the serial elements in
"sourceObject" are accessed each time Reckon[Stream[n]]
is invoked (untill Stream[Noop]).
During the life of the StreamObject
created by (4), it will have an associated StringName,
which is the external named source, in this case, "sourceObject",
which identifies the StreamSource. This StringName
is assigned to...
Stream[n][Name]
...while Stream[n]
exists.
The procedure used to access
the sourceObject
is performed by the Stream[Name[Function]].
If this attempt fails, an error with the form, Noop[Stream[Name]["sourceObject"]][...]
is returned. This Noop-standard should be kept by anyone
planning to edit the Stream[Name[Function]]
(See NoopNamedError).
The Function
used to mediate access to "sourceObject" is defined
immediately below.
(5) Stream[Name[Function]]["sourceObject"]
The Function, assigned to Stream[Name[Function]], is called the StreamNameFunction. It takes the String "sourceObject", (which is not a Name), and implements the rules whereby "sourceObject" is interpreted to access a Stream. Typically, a "sourceObject" is a ContextName which is translated into a file name or a Universal Source Locator (URL).
By convention, the StreamNameFunction interprets its String argument first as a ContextName, then as a Universal Source Locator (a.k.a. Uniform Source Identifiers), and finally as a local filename. If the String argument is still unrecognized, there may be other means of interpretation.
If a Stream
is successfully created, then an indexed StreamObject
(2)
is returned.
When the StreamObject reaches its last element,
any further attempt to read (as in (7)),
or any attempt to specify a Slot position in a StreamObject
which does not exist, will return...
(6)
Stream[Noop]
...which is called the EndOfFile or eof
when the Stream originates from a file.
A StreamObject
has indefinite extent. For this reason, it is not an error to attempt
to access a StreamObject beyond its extent. Attempts
to access an element after the last returns (6).
Stream[Noop] is unassigned and protected.
A freshly created StreamObject begins at StreamSlot
0 (zero).
If strm is a StreamObject, then each time strm is
Reckoned
(read), as in...
(7)
Reckon[strm]
...it returns an element from
the Stream and increments the StreamSlot.
The StreamObject,
Stream[n], remains alive until it is destroyed.
(8) Noop[Stream[n]]
...attempts to destroy Stream[n]. If Stream[n]
is destroyed, n is returned.
If something prevents Stream[n]
from being destroyed, an appropriate Noop[Stream[n]][...]
(NoopNamedError)
is returned.
"Stream[n]"
is used as the Head for the various StreamObject
fields. All have the form...
(9)
Stream[n][FieldName]
...where FieldName
is Type, Slot,
Type[Cardinal], or Name and return Stream[n]'s
DataType,
StreamPosition,
ElementSize,
or SourceNameString respectively.
FieldName
Elicitation
- Type Stream[n][Type]
...returns the Stream
element's DataType.
- Slot Stream[n][Slot]
...returns a Cardinal
that is Stream[n]'s current position.
- Type[Cardinal] Stream[n][Type[Cardinal]]
...returns the byte-size
of Stream[n]'s current element.
- Name Stream[n][Name]
...returns the originating StreamNameSource
String.
There are fixed-element-sized
Streams, and those with
varying element size. For example, the StreamObject
creating a CharacterStream from a String...
strm = Stream[String[...]]
...is presumed
to have varying element size because a String
is a sequence of Characters of varying byte size.
For such Streams,
the "Type[Cardinal]" field specifies the
size, in
bytes, of the element returned by...
Reckon[strm]
The "Type[Cardinal]"
field anticipates the size of the current Stream
element.
If strm is a StreamObject,
then specific elements may be accessed (read) by position with the
following construction:
(10)
Slot[slotSpec][strm]
...where slotSpec
is a SlotSpecification
that specifies the position(s) of the desired Stream
element in strm. The first element in the slotSpec
specifies the Stream element(s).
Subsequent elements in slotSpec specify slots within the
selected element(s). If (10) successfully accesses strm,
the Stream will be left at the position
after the last element accessed.
Experience is a sequence of discrete event
streams serially connected by consciousness. E.G.
"First I had breakfast, then
I drank coffee, and read the paper. Soon it was time to go to work."
This an example of a process
stream connected implicitly and explicitly by the "and" conjugation and
an ego, (which is the "master" procedure).
Grok32` manages the minutia
of Stream Logic...
If "...strm..." is a sequence of StreamObjects, then Or[...strm...] streams in parallel; And[...strm...] streams in sequence.
If "...strm..."
is a sequence
of StreamObjects, then...
(11)
And[...strm...]
...joins each StreamObject in ordered sequence to create a new serial StreamObject.
If "...strm..." is a sequence of StreamObjects,
then...
(12)
Or[...strm...]
...joins each of the StreamObjects
in �...strm..." in parallel to produce a StreamObject
whose elements are ordered Sequences
with elements from each of the �...strm...".
The order in the Stream sequence,
�...strm...", determines the order used to sequence
each element in the
resulting StreamObject.
In other words, Or[...strm...]
creates a StreamObject whose elements are a Sequence
constructed from each current element from each of the "...strm...".
If Stream[n]
is a StreamObject,
and "fileName" is either a ContextName,
a Uniform Source Identifier, or a local filename,
then...
(13)
Compile[Stream[n]]["fileName"]
(* write
StreamN to "filename". *)
...writes the nth StreamObject to "fileName" starting from its current position.
In other words, Stream[n]'s
fields and elements are recorded into "fileName"
when (13) is executed.
If the above write
is successful, subsequently invoking...
...should return a new StreamObject, Stream[m], such that Stream[m][Name] is assigned to "fileName".
stream n.
3. Anything issuing or moving with continued succession of parts; as, a stream of words.
"Stream of beneficence." Atterbury.
"Stream of emigration." Macaulay.
4. A continued current or course; current; drift; as, the stream of history; he lived and moved in the stream of fashionable society.
"The very stream of his life." Shak.
stream v.
1. To issue or flow in a stream; to issue freely or move in a continuous flow or course, as a fluid; as, tears streamed from her eyes; his words streamed forth.
Beneath those banks where rivers stream. Milton.
2. To pour out, or emit, a
stream or streams; as, streaming eyes; streaming eaves; my face was
streaming with sweat.
[From Websters1949Unabridged.]
(c) 2004-2008 by
John Van Wie Bergamini.