relax inout rules?

Jesse Phillips jessekphillips+d at gmail.com
Mon Dec 12 21:57:28 PST 2011


On Mon, 12 Dec 2011 13:56:43 -0500, Steven Schveighoffer wrote:

> The example we were discussing on the other thread was this:
> 
> void foo(ref inout(int)* a, inout(int)* b) { a = b;}

Is this just so it is easier to explain inout and won't have to explain 
that const will do the same thing? Or does this actually do something 
using const there doesn't?

void f(ref const(int)* a, const(int)* b) {a = b; }
void main() {
   const(int)* a;
   immutable(int)* b;
   auto c = (new int[](5)).ptr;
   f(a, c);
   f(b, c); //test.d(7): Error: cast(const(int)*)b is not an lvalue
}


More information about the Digitalmars-d mailing list