As for the lifetime issue, I'm for a more generic solution (which I think has been discussed earlier), namely a modifier where the storage is named explicitly. Something like this:
class X { int f() { // c is visible only in f but stored in the object instance. storage(X) int c; return c++; } }
class X { int f() { // c is visible only in f but stored in the topmost class instance. storage(global::this) int c; return c++; } }
(That could theoretically also be extended to quite wild things:
void kilroy (object x) { // Attach our own value to x. storage(x) marker = "kilroy was here"; }
But I'm not particularly keen on taking it that far.)