digitalmars.D - Improving (foreach) ranges
- Robert Clipsham <robert octarineparrot.com> Jun 09 2011
- Andrej Mitrovic <andrej.mitrovich gmail.com> Jun 09 2011
- eles <eles eles.com> Jun 11 2011
- "Robert Jacques" <sandford jhu.edu> Jun 09 2011
With the introduction of std.parallelism, I've been wondering about the
following:
foreach (i; 0..100)
{
}
For most uses of foreach, you can just wrap the range in parallel(), but
with a foreach range statement you can't do this. Of course iota() could
be used:
foreach (i; parallel(iota(0, 100)))
{
}
But that seems inconsistent. What are people's thoughts on making the
syntax a..b more general, so you can do eg:
void foo(int[]);
foo(0..100);
Although, I seem to recall seeing this conversation elsewhere, let me
know if this is the case.
--
Robert
http://octarineparrot.com/
Jun 09 2011
Yeah there was a big discussion about this IIRC. I can't recall the exact link to the topic, sorry.
Jun 09 2011
And the multi-dimensional slicing discussions tend to advocate mapping a..b to [a,b].
which would be such a shame...
Jun 11 2011
On Thu, 09 Jun 2011 19:58:34 -0400, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:Yeah there was a big discussion about this IIRC. I can't recall the exact link to the topic, sorry.
I know one of them was during tuple discussions. i.e. to use a..b..c instead of (a,b,c) The principal rational was a) '(,)' already has other meanings in D and b) '..' would allow for multi-dimensional slicing. But people felt this was ugly. And the multi-dimensional slicing discussions tend to advocate mapping a..b to [a,b].
Jun 09 2011









eles <eles eles.com> 