On Sun, May 1, 2016, at 21:02, Steven D'Aprano wrote:
Now imagine that you are a beginner, trying to understand this code block. What would you think it does? Might you not be surprised that the two references to ".attr" refer to different variables?
And of course there is always the objection that the barrier to adding a new keyword is quite high. Somewhere out there, somebody is using "using" as a variable name (perhaps a decorator?) and making this a keyword will break her code. Is it worth it?
Or you could make it context-sensitive, with it being an identifier unless it's used in this construction. Not saying it's a good idea, just that it's technically an option.
Despite these objections, I'm cautiously interested in this. I don't think the objections are insurmountable, and if there is a significant gain in readability and performance, it may be worth while.
A cautious and tentative +1.
It may be worth you doing a survey of other languages and seeing if they have anything similar.
Is there any reason not to simply implement a performance optimization for the normal syntax? Is the behavior of code which reaches into the parent frame and modifies its local variables guaranteed?