Why is readStream on SequenceableCollection and not on Collection?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Why is readStream on SequenceableCollection and not on Collection?

Bart Gauquie
Dear list,

is there a specific reason readStream is defined on SequenceableCollection and not on Collection?

I want to for instance stream over a Set (in a non determined order). 

I tried to do readStream on a Set, but got an error that copyFrom:to: was not defined on Set; so:

ReadStream>>on: aCollection 

I think should read:

ReadStream>>on: aSequenceableCollection 


Or should I always use: collect: select: detect: protocols?

Any thoughts on this?

Kind Regards

Bart

--
imagination is more important than knowledge - Albert Einstein
Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein
Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein
The true sign of intelligence is not knowledge but imagination. - Albert Einstein
However beautiful the strategy, you should occasionally look at the results. - Sir Winston Churchill
It's not enough that we do our best; sometimes we have to do what's required. - Sir Winston Churchill

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Why is readStream on SequenceableCollection and not on Collection?

Stéphane Ducasse
did you try with nile?
because I forgot (of course doing too many things) but the difference between squeak and VW was that
we could not have a stream on something else than string and array. Now this may have  changed in squeak with the work of levente
or nicolas.
Stef

On Aug 24, 2010, at 1:11 PM, Bart Gauquie wrote:

> Dear list,
>
> is there a specific reason readStream is defined on SequenceableCollection and not on Collection?
>
> I want to for instance stream over a Set (in a non determined order).
>
> I tried to do readStream on a Set, but got an error that copyFrom:to: was not defined on Set; so:
>
> ReadStream>>on: aCollection
>
> I think should read:
>
> ReadStream>>on: aSequenceableCollection
>
>
> Or should I always use: collect: select: detect: protocols?
>
> Any thoughts on this?
>
> Kind Regards
>
> Bart
>
> --
> imagination is more important than knowledge - Albert Einstein
> Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein
> Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein
> The true sign of intelligence is not knowledge but imagination. - Albert Einstein
> However beautiful the strategy, you should occasionally look at the results. - Sir Winston Churchill
> It's not enough that we do our best; sometimes we have to do what's required. - Sir Winston Churchill
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Why is readStream on SequenceableCollection and not on Collection?

Schwab,Wilhelm K
This cropped up in Dolphin some years back.  IIRC, OA's answer was that streams historically worked on only Array and maybe something else.  Having said that, they relaxed a constraint because it was harmless and a good idea.

I'm not sure about streaming over a set; lack of order means that it might be tricky to maintain a reasonable position??



________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Stéphane Ducasse [[hidden email]]
Sent: Tuesday, August 24, 2010 7:18 AM
To: [hidden email]
Subject: Re: [Pharo-project] Why is readStream on SequenceableCollection and    not on Collection?

did you try with nile?
because I forgot (of course doing too many things) but the difference between squeak and VW was that
we could not have a stream on something else than string and array. Now this may have  changed in squeak with the work of levente
or nicolas.
Stef

On Aug 24, 2010, at 1:11 PM, Bart Gauquie wrote:

> Dear list,
>
> is there a specific reason readStream is defined on SequenceableCollection and not on Collection?
>
> I want to for instance stream over a Set (in a non determined order).
>
> I tried to do readStream on a Set, but got an error that copyFrom:to: was not defined on Set; so:
>
> ReadStream>>on: aCollection
>
> I think should read:
>
> ReadStream>>on: aSequenceableCollection
>
>
> Or should I always use: collect: select: detect: protocols?
>
> Any thoughts on this?
>
> Kind Regards
>
> Bart
>
> --
> imagination is more important than knowledge - Albert Einstein
> Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein
> Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein
> The true sign of intelligence is not knowledge but imagination. - Albert Einstein
> However beautiful the strategy, you should occasionally look at the results. - Sir Winston Churchill
> It's not enough that we do our best; sometimes we have to do what's required. - Sir Winston Churchill
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Why is readStream on SequenceableCollection and not on Collection?

Nicolas Cellier
2010/8/24 Schwab,Wilhelm K <[hidden email]>:
> This cropped up in Dolphin some years back.  IIRC, OA's answer was that streams historically worked on only Array and maybe something else.  Having said that, they relaxed a constraint because it was harmless and a good idea.
>
> I'm not sure about streaming over a set; lack of order means that it might be tricky to maintain a reasonable position??
>

Exactly, the Stream would hardly be positionable, unless you use a
sort of OrderedSet...
A ReadWriteStream would be problematic for the same reasons.

What would be the interest of such a Stream ?
(I mean something more than what just you can do with #do:or #add:)

Nicolas

>
>
> ________________________________________
> From: [hidden email] [[hidden email]] On Behalf Of Stéphane Ducasse [[hidden email]]
> Sent: Tuesday, August 24, 2010 7:18 AM
> To: [hidden email]
> Subject: Re: [Pharo-project] Why is readStream on SequenceableCollection and    not on Collection?
>
> did you try with nile?
> because I forgot (of course doing too many things) but the difference between squeak and VW was that
> we could not have a stream on something else than string and array. Now this may have  changed in squeak with the work of levente
> or nicolas.
> Stef
>
> On Aug 24, 2010, at 1:11 PM, Bart Gauquie wrote:
>
>> Dear list,
>>
>> is there a specific reason readStream is defined on SequenceableCollection and not on Collection?
>>
>> I want to for instance stream over a Set (in a non determined order).
>>
>> I tried to do readStream on a Set, but got an error that copyFrom:to: was not defined on Set; so:
>>
>> ReadStream>>on: aCollection
>>
>> I think should read:
>>
>> ReadStream>>on: aSequenceableCollection
>>
>>
>> Or should I always use: collect: select: detect: protocols?
>>
>> Any thoughts on this?
>>
>> Kind Regards
>>
>> Bart
>>
>> --
>> imagination is more important than knowledge - Albert Einstein
>> Logic will get you from A to B. Imagination will take you everywhere - Albert Einstein
>> Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. - Albert Einstein
>> The true sign of intelligence is not knowledge but imagination. - Albert Einstein
>> However beautiful the strategy, you should occasionally look at the results. - Sir Winston Churchill
>> It's not enough that we do our best; sometimes we have to do what's required. - Sir Winston Churchill
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Why is readStream on SequenceableCollection and not on Collection?

Henrik Sperre Johansen


Den 24.08.2010 17:58, skrev Nicolas Cellier:

> 2010/8/24 Schwab,Wilhelm K <[hidden email]>:
>  
>> This cropped up in Dolphin some years back.  IIRC, OA's answer was that streams historically worked on only Array and maybe something else.  Having said that, they relaxed a constraint because it was harmless and a good idea.
>>
>> I'm not sure about streaming over a set; lack of order means that it might be tricky to maintain a reasonable position??
>>
>>    
> Exactly, the Stream would hardly be positionable, unless you use a
> sort of OrderedSet...
> A ReadWriteStream would be problematic for the same reasons.
>
> What would be the interest of such a Stream ?
> (I mean something more than what just you can do with #do:or #add:)
>
> Nicolas
+1.
I don't quite see what use could would find in a stream  of a
non-sequenced source that is not better served by using a different
abstraction, or the source itself..

Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Why is readStream on SequenceableCollection and not on Collection?

Bart Gauquie


On Wed, Aug 25, 2010 at 10:38 AM, Henrik Johansen <[hidden email]> wrote:


Den 24.08.2010 17:58, skrev Nicolas Cellier:
> 2010/8/24 Schwab,Wilhelm K <[hidden email]>:
>
>> This cropped up in Dolphin some years back.  IIRC, OA's answer was that streams historically worked on only Array and maybe something else.  Having said that, they relaxed a constraint because it was harmless and a good idea.
>>
>> I'm not sure about streaming over a set; lack of order means that it might be tricky to maintain a reasonable position??
>>
>>
> Exactly, the Stream would hardly be positionable, unless you use a
> sort of OrderedSet...
> A ReadWriteStream would be problematic for the same reasons.
>
> What would be the interest of such a Stream ?
> (I mean something more than what just you can do with #do:or #add:)
>
> Nicolas
+1.
I don't quite see what use could would find in a stream  of a
non-sequenced source that is not better served by using a different
abstraction, or the source itself..

Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


Ok, but why can you then do a collect:[] / select:[] / do: [] over a set? It also iterates over all the elements.  So why is it then strange to have a readstream over a set? I'm not saying it should be a positionable stream. 

But I also agree that is more logical to only do a ReadStream over a SequenceableCollection if you take into account positions ... Maybe change the code so that it only accepts a SequenceableCollection? 

Haven't tried Nile yet.

Kind Regards,

Bart

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Why is readStream on SequenceableCollection and not on Collection?

Henrik Sperre Johansen
Den 25.08.2010 12:58, skrev Bart Gauquie:


On Wed, Aug 25, 2010 at 10:38 AM, Henrik Johansen <[hidden email]> wrote:


Den 24.08.2010 17:58, skrev Nicolas Cellier:
> 2010/8/24 Schwab,Wilhelm K <[hidden email]>:
>
>> This cropped up in Dolphin some years back.  IIRC, OA's answer was that streams historically worked on only Array and maybe something else.  Having said that, they relaxed a constraint because it was harmless and a good idea.
>>
>> I'm not sure about streaming over a set; lack of order means that it might be tricky to maintain a reasonable position??
>>
>>
> Exactly, the Stream would hardly be positionable, unless you use a
> sort of OrderedSet...
> A ReadWriteStream would be problematic for the same reasons.
>
> What would be the interest of such a Stream ?
> (I mean something more than what just you can do with #do:or #add:)
>
> Nicolas
+1.
I don't quite see what use could would find in a stream  of a
non-sequenced source that is not better served by using a different
abstraction, or the source itself..

Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


Ok, but why can you then do a collect:[] / select:[] / do: [] over a set? It also iterates over all the elements.  So why is it then strange to have a readstream over a set? I'm not saying it should be a positionable stream. 

But I also agree that is more logical to only do a ReadStream over a SequenceableCollection if you take into account positions ... Maybe change the code so that it only accepts a SequenceableCollection? 

Haven't tried Nile yet.

Kind Regards,

Bart
Yes they iterate of the elements, but they don't really care about which. sequence the elements are in.
Sure you can write a block to pass to them which does, but I doubt you'd want to use that with a Set or a Dictionary.
 #next, #nextPut:, #upTo: and the rest of the Stream protocol certainly do care what sequence the elements are in.

Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project