On Jan 23, 4:53 am, Christophe Grand <christo...@cgrand.net> wrote:
> Christophe Grand a écrit :> I relaxed the constraint saying that "a stream
> ensures that /*every call
> > to seq on a stream will return the same seq" to be */"a stream ensures
> > that /*every call to seq on a stream will return the same seq as long as
> > the stream state doesn't change".*/
> > /*What did I lose?
>
> > Christophe
> > */
>
> /* and */ are by courtesy of Thunderbird :-(
>
> I relaxed the constraint saying that "a stream ensures that every call
> to seq on a stream will return the same seq" to be "a stream ensures
> that every call to seq on a stream will return the same seq as long as
> the stream state doesn't change".
>
> What did I lose?
I think you lose the game overall. The entire point of this mechanism
is to prevent the dissemination of stateful things. seq being a true
(referentially transparent) function of a stream is a critical part of
that. It ensures that when you've got a seq on a stream, you have
exclusive access to a pipe with no leaks. Inside the pipe, there may
be mutation and state, but no one can see them, since the end, seq,
view is persistent and immutable.
With what you are proposing:
(if (seq astream)
(do-something-with (first astream))
is broken.
More generally, I guess I simply don't understand these use cases for
treating the stream as a seq and subsequently mutating it. Maybe I
should rename them pipes and it would be less likely people would
expect them to divide and run all over the mountain :)
Seriously, is there a real use case for (first astream) ... (take1
astream) ?
You should presume there will be stream version of all the sequence
fns.
Rich
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---