You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Benjamin Mahler <be...@gmail.com> on 2015/08/05 02:18:17 UTC

Range-based for loops

I noticed there was a single ranged-based for loop introduced in the source
tree:

https://github.com/apache/mesos/blob/master/src/tests/resources_tests.cpp#L1004

Since this is the only one in the codebase AFAICT, I've removed it to keep
our use of 'foreach' consistent. Michael, is there a plan to replace
'foreach' with range-based for loops? Would just like there to be a
consistent way to loop over containers. :)

Re: Range-based for loops

Posted by Benjamin Mahler <be...@gmail.com>.
No worries, thanks for the follow-up!

On Wed, Aug 5, 2015 at 6:20 PM, Michael Park <mc...@gmail.com> wrote:

> Looks like I introduced it initially, sorry about that.
>
> Michael, is there a plan to replace 'foreach' with range-based for loops?
>
>
> I've thought about this and I don't know exactly how we would want to do
> it as a community.
> I've filed MESOS-3214 <https://issues.apache.org/jira/browse/MESOS-3214> with
> listing 2 possible approaches.
>
> Please share your thoughts and preferences there!
>
> Thanks,
>
> MPark.
>
> On 4 August 2015 at 20:19, Artem Harutyunyan <ar...@mesosphere.io> wrote:
>
>> We should also come up with the recommended way of dealing with
>> foreachpair and foreachvalue occurrences. I did a quick grep and there
>> seem to be over 900 places where foreach(value/pair) are used. It's
>> going to be quite a change (albeit a straightforward one), but we
>> should still be all for it :-).
>>
>> Cheers,
>> Artem.
>>
>>
>> On Tue, Aug 4, 2015 at 5:18 PM, Benjamin Mahler
>> <be...@gmail.com> wrote:
>> > I noticed there was a single ranged-based for loop introduced in the
>> source
>> > tree:
>> >
>> >
>> https://github.com/apache/mesos/blob/master/src/tests/resources_tests.cpp#L1004
>> >
>> > Since this is the only one in the codebase AFAICT, I've removed it to
>> keep
>> > our use of 'foreach' consistent. Michael, is there a plan to replace
>> > 'foreach' with range-based for loops? Would just like there to be a
>> > consistent way to loop over containers. :)
>>
>
>

Re: Range-based for loops

Posted by Michael Park <mc...@gmail.com>.
Looks like I introduced it initially, sorry about that.

Michael, is there a plan to replace 'foreach' with range-based for loops?


I've thought about this and I don't know exactly how we would want to do it
as a community.
I've filed MESOS-3214 <https://issues.apache.org/jira/browse/MESOS-3214> with
listing 2 possible approaches.

Please share your thoughts and preferences there!

Thanks,

MPark.

On 4 August 2015 at 20:19, Artem Harutyunyan <ar...@mesosphere.io> wrote:

> We should also come up with the recommended way of dealing with
> foreachpair and foreachvalue occurrences. I did a quick grep and there
> seem to be over 900 places where foreach(value/pair) are used. It's
> going to be quite a change (albeit a straightforward one), but we
> should still be all for it :-).
>
> Cheers,
> Artem.
>
>
> On Tue, Aug 4, 2015 at 5:18 PM, Benjamin Mahler
> <be...@gmail.com> wrote:
> > I noticed there was a single ranged-based for loop introduced in the
> source
> > tree:
> >
> >
> https://github.com/apache/mesos/blob/master/src/tests/resources_tests.cpp#L1004
> >
> > Since this is the only one in the codebase AFAICT, I've removed it to
> keep
> > our use of 'foreach' consistent. Michael, is there a plan to replace
> > 'foreach' with range-based for loops? Would just like there to be a
> > consistent way to loop over containers. :)
>

Re: Range-based for loops

Posted by Artem Harutyunyan <ar...@mesosphere.io>.
We should also come up with the recommended way of dealing with
foreachpair and foreachvalue occurrences. I did a quick grep and there
seem to be over 900 places where foreach(value/pair) are used. It's
going to be quite a change (albeit a straightforward one), but we
should still be all for it :-).

Cheers,
Artem.


On Tue, Aug 4, 2015 at 5:18 PM, Benjamin Mahler
<be...@gmail.com> wrote:
> I noticed there was a single ranged-based for loop introduced in the source
> tree:
>
> https://github.com/apache/mesos/blob/master/src/tests/resources_tests.cpp#L1004
>
> Since this is the only one in the codebase AFAICT, I've removed it to keep
> our use of 'foreach' consistent. Michael, is there a plan to replace
> 'foreach' with range-based for loops? Would just like there to be a
> consistent way to loop over containers. :)