March 19, 2014
On 3/19/14, 9:09 AM, Dicebot wrote:
> On Wednesday, 19 March 2014 at 16:04:16 UTC, Andrei Alexandrescu wrote:
>> tee is already being discussed -- Andrei
>
> On this topic, do we have something like "consume" in Phobos to eagerly
> iterate through the supplied range?

A default "each" would do that.

Andrei
March 19, 2014
On 3/19/14, 9:10 AM, Timon Gehr wrote:
> On 03/19/2014 05:01 PM, Andrei Alexandrescu wrote:
>> On 3/19/14, 8:55 AM, Dicebot wrote:
>>> I would have supported if it was lazy. Not in its proposed form.
>>
>> Good point. Maybe forall would be a better name.
>>
>> Andrei
>
> http://en.wikipedia.org/wiki/Forall

Never mind, each is better :o) -- Andrei
March 19, 2014
On Wednesday, 19 March 2014 at 16:09:31 UTC, Dicebot wrote:
> On Wednesday, 19 March 2014 at 16:04:16 UTC, Andrei Alexandrescu wrote:
>> tee is already being discussed -- Andrei
>
> On this topic, do we have something like "consume" in Phobos to eagerly iterate through the supplied range?

I had proposed "walk", which would be consistent with the already existing "walkLength".

An "each()" with no arg could also do the trick, but that would also call the "front", which means it's not the exact same behavior (not better or worst, just different).
March 19, 2014
On Wednesday, 19 March 2014 at 16:40:24 UTC, Andrei Alexandrescu wrote:
> On 3/19/14, 9:09 AM, Dicebot wrote:
>> On Wednesday, 19 March 2014 at 16:04:16 UTC, Andrei Alexandrescu wrote:
>>> tee is already being discussed -- Andrei
>>
>> On this topic, do we have something like "consume" in Phobos to eagerly
>> iterate through the supplied range?
>
> A default "each" would do that.
>
> Andrei

No, I don't mean iterate with predicate. I mean /dev/null thing.

My point is that `range.each!predicate` is much better replaced with `range.tap!predicate.consume`. It keeps general rule of range stuff being lazy and only single exception to bail out of it has very readable clear name.

One can argue that "consume" is same as proposed "each" with no-op predicate but I think it is very important for readability to keep exceptional behavior (eager consumption) separated from utility behavior (tapping with a predicate).
March 19, 2014
On Wednesday, 19 March 2014 at 16:46:41 UTC, Dicebot wrote:
> No, I don't mean iterate with predicate. I mean /dev/null thing.
>
> My point is that `range.each!predicate` is much better replaced with `range.tap!predicate.consume`. It keeps general rule of range stuff being lazy and only single exception to bail out of it has very readable clear name.
>
> One can argue that "consume" is same as proposed "each" with no-op predicate but I think it is very important for readability to keep exceptional behavior (eager consumption) separated from utility behavior (tapping with a predicate).

I also proposed this in the thread I linked, but it was also rejected. I remember Andrei saying that "consume" should really just be reduce called with no predicate, but I think that wouldn't work for some reason...
March 19, 2014
On 3/19/14, 9:46 AM, Dicebot wrote:
> On Wednesday, 19 March 2014 at 16:40:24 UTC, Andrei Alexandrescu wrote:
>> On 3/19/14, 9:09 AM, Dicebot wrote:
>>> On Wednesday, 19 March 2014 at 16:04:16 UTC, Andrei Alexandrescu wrote:
>>>> tee is already being discussed -- Andrei
>>>
>>> On this topic, do we have something like "consume" in Phobos to eagerly
>>> iterate through the supplied range?
>>
>> A default "each" would do that.
>>
>> Andrei
>
> No, I don't mean iterate with predicate. I mean /dev/null thing.

So did I - "each" could take a default alias. -- Andrei
March 19, 2014
On Wednesday, 19 March 2014 at 17:39:16 UTC, Andrei Alexandrescu wrote:
> So did I - "each" could take a default alias. -- Andrei

We could have saved some time if you have replied directly to my objection to your objection I have foreseen :P (see last part of the comment)
March 19, 2014
On Wednesday, 19 March 2014 at 16:46:41 UTC, Dicebot wrote:
> My point is that `range.each!predicate` is much better replaced with `range.tap!predicate.consume`. It keeps general rule of range stuff being lazy and only single exception to bail out of it has very readable clear name.
>
> One can argue that "consume" is same as proposed "each" with no-op predicate but I think it is very important for readability to keep exceptional behavior (eager consumption) separated from utility behavior (tapping with a predicate).

This. I fully agree.
March 19, 2014
On 3/19/2014 8:06 AM, Andrei Alexandrescu wrote:
> Pros and cons are already being discussed. Destroy!


I don't have a solid enough experience with this style of programming, but one opportunity of 'each' could be that it could be specialized and achieve greater speed for some arguments.
March 19, 2014
On 3/19/2014 8:55 AM, Dicebot wrote:
> I would have supported if it was lazy. Not in its proposed form.

Also if it is implicitly parallelizable or not, i.e. are there traversal order dependencies?