Explicit frame ref? (was Re: Declaring setters with getters)
At 07:01 AM 11/1/2007 -0700, Guido van Rossum wrote:
However I don't approve of it. It has always been and will always continue to be my position that these are semantically unkosher, because it means that you can't wrap them in convenience functions or invoke them in different contexts, and that means that the semantics are hard to explain.
This is semi-random tangent, but what if there was a way to explicitly refer to the current frame as a function argument? Then, the implicitness that creates these problems becomes explicit, instead. As it happens, I write virtually all my frame-oriented decorators to take a 'frame' argument anyway, and only guess when it's not supplied. So, having a convenient way to pass the argument would be the only thing needed. Unfortunately, to be really useful, the name or symbol used would have to be more compact than the name or other data that you planned to get from the frame in the first place. "sys._getframe()" itself, for example, is way too long of a string. Even shortening this to something like 'here()' still seems too inconvenient, but to go any less than that invites the use of line-noise for syntax. Oh well, it was worth a try.
participants (1)
-
Phillip J. Eby