On Thursday, 31 January 2013 at 21:31:08 UTC, Ali Çehreli wrote:
On 01/31/2013 08:59 AM, bioinfornatics wrote:
> I think when i iterate over a phobos range :
> foreach( state, letter; fastq )
> and if fastq instance is called into this loop as done at
line 181 is
> not the same instance

Correct. Here is a simpler program:

import std.stdio;

struct S
{
    int i;

    @property int front() const
    {
        writefln("front   : %s", &i);
        return i;
    }

    @property bool empty() const
    {
        writefln("empty   : %s", &i);
        return i == 0;
    }

    void popFront()
    {
        writefln("popFront: %s", &i);
        --i;
    }
}

void main()
{
    auto s = S(2);
    writefln("main    : %s", &s.i);

    foreach (i; s) {
    }
}

The object in main is a different object:

main    : 7FFFBD429B70
empty   : 7FFFBD429B74
front   : 7FFFBD429B74
popFront: 7FFFBD429B74
empty   : 7FFFBD429B74
front   : 7FFFBD429B74
popFront: 7FFFBD429B74
empty   : 7FFFBD429B74

Ali

is normal or is a bug ?

Reply via email to