If you create a class/struct that can give you a (forward) range
via "opSlice()", and that range gives you access to "opApply",
then you get two different behaviors:
MyClass arr = ...;
foreach(a; arr)
...
foreach(a; arr[])
...
In the first case, foreach will call opSlice(), a
"monarch_dodra" , dans le message (digitalmars.D:171868), a écrit :
> I'm wondering if this is the correct behavior? In particular,
> since foreach guarantees a call to opSlice(), so writing "arr[]"
> *should* be redundant, yet the final behavior is different.
>
> That said, the "issue" *could*
On Wednesday, 11 July 2012 at 14:10:35 UTC,
trav...@phare.normalesup.org (Christophe Travert) wrote:
I think foreach should never call opSlice. That's not in the
online
documentation
(http://dlang.org/statement.html#ForeachStatement), unless
I missed something. If you want to use foreach on a cl
I think the online documentation
(http://dlang.org/statement.html#ForeachStatement) is not sufficient.
foreach (e; aggr) { ...body...}
Current dmd translates above foreach statement like follows.
1. If aggr has opApply or opApplyReverse, it's used.
2. If aggr has empty/front/popFront:
2a. If a
"monarch_dodra" , dans le message (digitalmars.D:171902), a écrit :
> I just re-read the docs you linked to, and if that was my only
> source, I'd reach the same conclusion as you.
I think the reference spec for D should be the community driven and
widely available website, not a commercial book
On Wednesday, July 11, 2012 14:10:35 Christophe Travert wrote:
> "monarch_dodra" , dans le message (digitalmars.D:171868), a écrit :
> > I'm wondering if this is the correct behavior? In particular,
> > since foreach guarantees a call to opSlice(), so writing "arr[]"
> > *should* be redundant, yet
On Wednesday, July 11, 2012 15:43:13 Christophe Travert wrote:
> "monarch_dodra" , dans le message (digitalmars.D:171902), a écrit :
> > I just re-read the docs you linked to, and if that was my only
> > source, I'd reach the same conclusion as you.
>
> I think the reference spec for D should be t
On Wednesday, 11 July 2012 at 20:24:42 UTC, Jonathan M Davis
wrote:
The problem is that it's essentially spread out across 3
places: the online
spec, TDPL, and the compiler.
...
- Jonathan M Davis
The problem is not only the documentation, it's getting
authoritative answers. I see some stra
On 07/12/2012 04:50 PM, monarch_dodra wrote:
On Wednesday, 11 July 2012 at 20:24:42 UTC, Jonathan M Davis wrote:
The problem is that it's essentially spread out across 3 places: the
online
spec, TDPL, and the compiler.
...
- Jonathan M Davis
The problem is not only the documentation, it's ge
On Wed, 11 Jul 2012 11:10:16 -0400, kenji hara wrote:
I think the online documentation
(http://dlang.org/statement.html#ForeachStatement) is not sufficient.
foreach (e; aggr) { ...body...}
Current dmd translates above foreach statement like follows.
1. If aggr has opApply or opApplyReverse,
On Thursday, 12 July 2012 at 21:18:21 UTC, Steven Schveighoffer
wrote:
If opSlice is to be used, this is how it should go (in order of
precedence):
1. if aggr has opApply or opApplyReverse, use it.
2. if aggr has opSlice, and the result of aggr.opSlice() has
opApply or opApplyReverse, use i
On Thu, 12 Jul 2012 17:35:23 -0400, monarch_dodra
wrote:
On Thursday, 12 July 2012 at 21:18:21 UTC, Steven Schveighoffer wrote:
If opSlice is to be used, this is how it should go (in order of
precedence):
1. if aggr has opApply or opApplyReverse, use it.
2. if aggr has opSlice, and the
On Thursday, 12 July 2012 at 22:02:19 UTC, Steven Schveighoffer
wrote:
On Thu, 12 Jul 2012 17:35:23 -0400, monarch_dodra
wrote:
On Thursday, 12 July 2012 at 21:18:21 UTC, Steven
Schveighoffer wrote:
If opSlice is to be used, this is how it should go (in order
of precedence):
1. if aggr h
On Fri, 13 Jul 2012 02:20:45 -0400, monarch_dodra
wrote:
On Thursday, 12 July 2012 at 22:02:19 UTC, Steven Schveighoffer wrote:
On Thu, 12 Jul 2012 17:35:23 -0400, monarch_dodra
wrote:
On Thursday, 12 July 2012 at 21:18:21 UTC, Steven Schveighoffer wrote:
If opSlice is to be used, thi
On Thursday, July 12, 2012 16:50:22 monarch_dodra wrote:
> On Wednesday, 11 July 2012 at 20:24:42 UTC, Jonathan M Davis
>
> wrote:
> > The problem is that it's essentially spread out across 3
> > places: the online
> > spec, TDPL, and the compiler.
> >
> > ...
> >
> > - Jonathan M Davis
>
> The
On Sunday, 15 July 2012 at 20:01:35 UTC, Jonathan M Davis wrote:
Ideally, we wouldn't even need opApply anymore
AFAIT, that's impossible.
Not because of D, but because of other stuff.
Lots of functions require callbacks for enumeration (e.g.
EnumChildWindows in Windows); it's simply impossib
On Monday, 16 July 2012 at 06:27:13 UTC, Mehrdad wrote:
On Sunday, 15 July 2012 at 20:01:35 UTC, Jonathan M Davis wrote:
Ideally, we wouldn't even need opApply anymore
AFAIT, that's impossible.
Not because of D […]
How else woud you implement things like parallel foreach, …?
David
On Monday, July 16, 2012 09:47:50 David Nadlinger wrote:
> On Monday, 16 July 2012 at 06:27:13 UTC, Mehrdad wrote:
> > On Sunday, 15 July 2012 at 20:01:35 UTC, Jonathan M Davis wrote:
> >> Ideally, we wouldn't even need opApply anymore
> >
> > AFAIT, that's impossible.
> >
> > Not because of D […
On Monday, 16 July 2012 at 08:13:49 UTC, Jonathan M Davis wrote:
On Monday, July 16, 2012 09:47:50 David Nadlinger wrote:
On Monday, 16 July 2012 at 06:27:13 UTC, Mehrdad wrote:
> AFAIT, that's impossible.
>
> Not because of D […]
How else woud you implement things like parallel foreach, …?
19 matches
Mail list logo