|
From: Twylite <tw...@cr...> - 2008-06-16 20:13:07
|
Hi, > From: "Donal K. Fellows" <don...@ma...> > The way forward has to be explicit declaration somewhere, and a > class-level declaration of variables seems reasonable and an automatic > availability of the variables in methods at the same level (i.e. that > are normally in reasonably close proximity to the variable declarations) > gets a fair balance between various forms of maintainability. Subclasses > that want automatic access to the same variables will have to say so for > themselves (i.e. the variable lists aren't inherited, and can't be > because that would take us back into the known-problematic all-visible > case). > Shouldn't we be looking at an instance-variable equivalent of what "namespace import" does for procs? >> > In general this feature has much potential for confusion since it breaks >> > locality and makes therefore maintenance more complex. >> > "Breaks locality"? Either you've misread the TIP (could be; it's a first > draft, not a final version) or you're arguing for stronger isolation > than I think is Tcl-ish. (See my comments above about naming schemes.) > Unless I'm arguing something else entirely (which is quite possible) it breaks locality and is un-Tclish by automatically bring non-local variables into local scope. This means that there is one behavior for procs and another for methods. And no - it's not expected behaviour. In C and many other languages globals are available in all scopes, namespace variables are available to all procedures in that namespace, and by logical extension instance variables are available to all methods. The same logical extension does not hold for Tcl, as non-local variables are never implicitly available. > Actually, I hope it's the isolation argument. That's by far the most > interesting one. :-D > Happy to oblige :) >> > Also global variables are namespaced variables are explicitly >> > imported into a proc scope via commands. >> > The scoping of variables (proc scope, global, namespace, >> > instance variable) in a single method should be clear just by looking >> > at this method, not by searching around for potential places. >> > That's the status quo. My impression (from discussion on this list) was > that that was unacceptable. > My impression was that there needs to be a mechanism to allow for implicit access to instance variables. I believe the jury was still out on whether that mechanism was enabled by default, and whether it could be disabled. Regards, Twylite |