On Monday, 11 February 2013 at 23:16:55 UTC, Peter Alexander wrote:
On Monday, 11 February 2013 at 06:52:33 UTC, deadalnix wrote:
I'm thinking about it for a while now and I'm now convinced that we should allow the compiler to do that job for us. Let me explain.

struct Foo { int x, y; }

class Bar
{
    Foo[] foos = [Foo(1, 2)];

    void swap(const(Foo) f)
    {
        foos[0].x = f.y;
        foos[0].y = f.x;
    }
}

void quux(Bar bar, const(Foo) foo)
{
    bar.swap(foo);
}

Are the foo parameters allowed to be passed by ref in both these functions? I see no reason why not from your criteria, but doing so changes the program.

I guess the constraint are too lax. Is it possible to get around that without creating a cascade of special cases ? I frankly don't know, I have to dig more into this.

Reply via email to