Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 11:58:22 UTC, Chris wrote: Sorry that should be: @property void popFront() { r = r[1..$]; cnt++; }

Re: Invalid foreach aggregate

2015-11-17 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 12:41:45 UTC, Chris wrote: On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote: In any case, I'd suggest you fix your opIndex(), except if there's a really good reason it is as it is. I see. Thanks for the explanation. What would be the easiest fix

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
I've checked several options now and it doesn't work. Here (http://dlang.org/statement.html#foreach-with-ranges) it is stated that it suffices to have range primitives, if opApply doesn't exist. My code worked up to 2.068.0, with the introduction of 2.068.1 it failed. I wonder why that is.

Re: Invalid foreach aggregate

2015-11-17 Thread Marc Schütz via Digitalmars-d-learn
: Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething) {} Probably not the best idea anyway. What's the best

Re: Invalid foreach aggregate

2015-11-17 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 11:58:22 UTC, Chris wrote: I did just that and I could find the culprit. It's opIndex(). It works up until 2.068.0, with 2.068.1 I already get this error: "primitives.d(7): Error: invalid foreach aggregate doSomething(items).opIndex()" @prope

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote: Ok, that's a strange implementation of opIndex(). Usually, a parameter-less opIndex() is supposed to return a slice into the full range, but yours returns a size_t, which of course can't be iterated over. The change that made

Re: Invalid foreach aggregate

2015-11-17 Thread Chris via Digitalmars-d-learn
already get this error: "primitives.d(7): Error: invalid foreach aggregate doSomething(items).opIndex()" Here's the example: = import std.stdio : writeln; import std.range.primitives; void main() { string[] items = ["a", "

Re: Invalid foreach aggregate

2015-11-16 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 16 November 2015 at 16:44:27 UTC, Chris wrote: Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething

Re: Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
On Monday, 16 November 2015 at 16:49:19 UTC, Marc Schütz wrote: On Monday, 16 November 2015 at 16:44:27 UTC, Chris wrote: Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives

Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
Updating my code from 2.067.1 to 2.069.1 (I skipped 2.068, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething) {} Probably not the best idea anyway. What's the best

Re: Invalid foreach aggregate

2015-11-16 Thread opla via Digitalmars-d-learn
foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething) {} Probably not the best idea anyway. What's the best fix for this? Thanks. Well, what does `doSomething` return? It returns a range that modifies individual items

Re: Invalid foreach aggregate

2015-11-16 Thread Chris via Digitalmars-d-learn
, because I was too busy). I get this error: invalid foreach aggregate, define opApply(), range primitives, or use .tupleof for code like foreach (ref it; myArray.doSomething) {} Probably not the best idea anyway. What's the best fix for this? Thanks. Well, what does `doSomething` return