On Monday, 1 July 2013 at 16:46:57 UTC, Ary Borenszweig wrote:
Ah, that's also ok. But then you have to remember to use myVar instead of var.

I have wanted to remove a variable from scope before. I think it would be kinda cool if we could do something like __undefine(x), and subsequent uses of it would be an error. (It could also prohibit redeclaration of it if we wanted.)

D doesn't have that, but we can get reasonably close using other functions when we change param types (just forward it to the other overload) and functions and/or scopes for local variables:

void foo() {
   { int a; /* use a */ }
// a is now gone, so you don't accidentally use it later in the function
}

Reply via email to