On Wednesday, 30 January 2013 at 02:29:12 UTC, Jonathan M Davis wrote:
But if we can do something like

struct S
{
    @property int prop;
}

then that fixes the problem.

I had a thought. What if we use this opportunity to also fix the problem with transient ranges. So... what if, instead of using the attribute @property for the purpose you suggest, we added a new attribute, let's say @noref, and that's what it would mean:

struct S
{
    @noref int value; // #1

    @noref ref const(float) front() const; // #2
}

S s;

#1: Can't take the address/reference of s.value

#2: Can't take the address/reference of s.front()

Transient ranges could notate their front method with @noref, which would prevent all incorrect use of them, and would enable their front to return by ref or const ref, instead of by value.

Reply via email to