[<<][staapl][>>][..]
Wed Apr 6 22:32:53 EDT 2011
Streams are cool
In my day-job embedded work I'm moving from data structures to streams
a lot. Main reason is to avoid intermediate lists.
My favourite abstraction is for-each with early abort. In C this
needs to be combined with the dual stream interface (open / rewind /
next / eof) because for-each can't be easily inverted (i.e using
partial continuations).
Anyways. Maybe this is also true for Forth, but then on one level
deeper: to treat structs as streams because indirect addressing
(structs) are a bit awkward to use: no support for the separate
namespaces. Doing so opens up the door for channel-based
multiprogramming, as a streamed structure read or write can easily be
replaced by a channel connecting producer and consumer.
Essentially this is the same transformation as going from named to
nameless arguments: use position instead of names to encode meaning.
I think a big idea is hidden here. Streams and state machines...
Actually it's not such a big deal: when memory is scarce, you
implement functionality as communicating state machines. Streams and
their associated parsers and printers are state machines, or state
machines embedded in push-down automata (state machine + stack) or
2-stack/tape machines.
[Reply][About]
[<<][staapl][>>][..]