Am 11.12.2011 19:00, schrieb Walter Bright:
On 12/11/2011 9:07 AM, Mafi wrote:
But what about:
void f(ref inout(int)* a, inout(int)* b) { a = b; }
This cant work with const because that would violate the const system.
I think
the rule should be that either the return type must be inout or at
least one
ref/out parameter.
Am I overlooking something?
It should work with const.
But allowing a variable of type abc(int)* where abc is immutable or
nothing (ie mutable) to be passed to a parameter of the type ref/out
const(int)* breaks the type system.
void f(ref const(int)* a, const(int)* b) {a = b; }
void main() {
immutable(int)* a;
auto b = (new int[](5)).ptr;
f(a, b);
//if this compiles I have just assigned a mutable pointer
//to an immutable one
}
With the above definition using inout, such a call would be disallowed.