On Tue, Jun 25, 2019 at 11:01 PM nate lust <natelust@linux.com> wrote:
This message is related to two previous threads, but was a sufficiently evolved to warrant a new topic.
I am proposing that two new magic methods be added to python that will control assignment and loading of class instances. This means that if an instance is bound to a variable name, any attempts to rebind that name will result in a call to the __setself__ (name negotiable) of the instance already bound to that name. Likewise when a class instance bound to a name is loaded by the interpreter, if present, the __getself__ method of that instance will be called and its result will be returned instead. I have been internally calling these cloaking variables as they "cloak" the underlying instance, parallelling the idea of shadowing. Feel free to suggest better names.
Very interesting and this will be much better than introducing new operators for DSLs! This makes Python finally treating "=" operator symmetric as rest of the operators, and I will definitely stop using descriptors forever if this feature gets accepted! I find the objection reasoning very strange as none of the default behavior changed, and yet if you use this feature you do need to worry about the object behavior regarding assignment, this is true for descriptors and all other magics.