I wrote before that I don't “use” stream programming, but I've come to realize that it's still how I think of algorithms and
for
loops. Input enters at the top, gets transformed in the middle, and yields output at the bottom.It's like I look at a
foreach
loop as an in-line lambda function. The concept may not be explicitly named, and the composition of steps built into lower-level control flow… but inside my head, it's still a “sequence of operations” on a “stream of data.”There doesn't seem to be much benefit to building up “real” streams in a language that doesn't have them either built-in or in the standard library. It creates another layer where the things that have been built can only interoperate with themselves, and a series of transformations can no longer share state. And, a PHP array can be passed to any
array_*
function, where (last I even checked) our handmade streams or Iterators cannot.
No comments:
Post a Comment