Summary: inout is allowed on fields
--- Comment #0 from Steven Schveighoffer <schvei...@yahoo.com> 2011-10-05
06:48:16 PDT ---
inout cannot be allowed to be an attribute for fields, since inout is
implicitly cast at the end of an inout function.
With this allowance, I can obtain a mutable pointer to an inout field, even
though it should be treated as const:
inout(int)* foo() inout
auto xp = s.foo();
*xp = 3;
assert(s.x == 3);
inout should be a temporary condition, only allowed for stack-stored types.
But fields can be placed outside the stack, since you can place any struct or
class outside the stack.
Alternatively, you could be able to declare a struct field as inout, and then
not allow that struct type to ever be placed anywhere but the stack. But I do
not see a good use case for that feature.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------