In some circumstances, it may be worth doing what you suggest, but I don't think so in this case. Not that it would cause any problems or anything, but I just think it serves no purpose.
It's not possible for there to be no V variable. Setting it is the first thing that happens after the *error* definition, and before any User input or opportunity to hit Escape or anything, and it's getting the OSMODE value, of which there always is one. So there is no circumstance that I can imagine under which (if V) would not return True, and therefore no reason to bother with an (if) function to run a test with only one possible result.
Putting V in the localized variables list is what "prevents possible gremlins from migrating to other programs" -- after all, that's the most important *purpose* of localizing variables, which causes them to disappear when the routine is done. So there is no reason to set it to nil in the error handler -- the ending of the routine does that. Even if there was, coincidentally, some value assigned to that same variable *name* by something else before, this routine will [again, if the variable is localized] only use its own internal value for it, ignoring the external prior value, and that prior value will be what remains when this routine is done, unaffected by its use inside this routine -- again, that's part of the purpose of localizing variables. In such a case, even setting a localized variable to nil inside the routine will not set that external variable with the same name to nil, but its prior value will remain.
The one set of circumstances under which I would agree that setting a variable to nil in an error handler is worth doing is this combination:
A. The variable is [and only for some really good reason] *not* localized within the function, such as if it needs to be retained for use by other calling functions or commands;
B. The variable is set by or after some opportunity for User input [meaning that the function might be cancelled, such as with Escape, or the User might give it some invalid value, which can usually be prevented anyway];
C. The variable could possibly contain a "wrong" value that could throw off another function, or possibly another running of the containing function [not just *no* value, because in that case it would already be nil].
All that about "the next program restores the previous error handler" and "a new error handler...overwrites the one I created" and "AutoCAD keeps writing new error handlers" is entirely irrelevant, if *error* is defined as a localized subroutine within functions that need error handling. Each function uses its own internally, resetting only what it needs to, and because they're localized, they disappear at the end of the running of each function, and AutoCAD's native error handler takes over again. Nothing from one routine overwrites anything from another.
--
Kent Cooper
Kent Cooper, AIA