On Monday, 29 December 2014 at 04:13:18 UTC, Andrei Alexandrescu wrote:
Walter's reasoning was: we have inout for propagating qualifiers from a parameter ("this" is also a parameter) to the output, so we can use it for propagating aliasing information as well.

Yay! I have been asking for it since scope threads started :)

I like the intention behind the DIP and I think idea itself is sound and fits naturally into existing language.

But this example confuses me:

@safe ref int wrongIdentity(ref int x) {
return x; // ERROR! Cannot return a ref, please use "ref inout"
}

@safe ref int identity(ref inout int x) {
    return x; // fine
}

If existing meaning of is to be kept too second example should look like this:

@safe ref inout int identity(ref inout int x) {
    return x; // fine
}

otherwise it allows silent casting of const reference to mutable one!

Reply via email to