'map' method, proposal of method name change

Krunoslav Magazin magazin9 at
Sun Aug 20 03:03:49 UTC 2017

Thank you all on comments. I have studied referenced sources and now I
will upgrade my initial comment in context of mentioned mutative
update. I find now that first question that need answer is what is the
definition of stream and how pipeline of operations relate to stream.

Method 'map' implies existence of materialized in/out streams. Example
is linear queue. This goes with definition on using list
as map source and output. Same I find in Haskell and Lisp usage of map
or mapcar function. Name of map function is indisputable as defined in
wiki resources. But is usage of that map function justified in java
streams ?
With java streams when implementation use operation fusion on pipeline
of operations there is no intermediary queue between operations.
chapter 'Stream versus collections', about fusion. This is
implementation specific ("how" to do it)

In common usage word stream represent current of elements. Stream
exist if there is at least one moving element. Without moving element
there is no stream. Stream have no state. Stream is agnostic on: 1)
element type; 2) source state; 3) target state.
This is how I see elements going through pipeline of operations when I
build sequence of operations ("what" to do with an element in
transition). Elements are emitted one by one from backed source
collection by stream() operation (stream source), going through
pipeline composed of filter() and map() operations, intermediate
operations like sorted() (ending one stream and emitting another) and
ending with the sink (collect(), count()...). Map method effectively
replaces element with computed one, stream doesn't care and source
collection is not affected. From this definition of stream goes that
operations are on the element, not on a stream (or collection with
state). This goes with my stand that word replace(With) would be
appropriate name for method, not map. If written description of stream
reflect streams library build up than usage of word map for method in
question is not justified here.

describe java streams library. It states that "Streams provide no
storage for the elements..." but in comment @Goetz said that 'replace'
implies mutative update. Am I missing something?

I will appreciate any comments.
Best regards,
Krunoslav Magazin

More information about the core-libs-dev mailing list