
Hi Paul I'm writing in response to one of your comments, all of which are useful. Please forgive me, Paul, for not responding to the others in this message. I wrote:
Next, the implementation of such K-mappings. Here, K.set and K.get decorators will help. Something like (not tested): class MyMap: @K.adjust_get def __getitem__(self, x1, x2, x3, a, b): pass where K.adjust_get interfaces between the K-object and the definition of __getitem__.
About this you wrote:
I have no idea how this works, or what it even means.
With hindsight, I can see your difficulty. The original idea is to extend the syntax so that >>> m = MyMap() >>> m[1, 2, 3, a=4, b=5] = 'foobar' is allowed in some future version of Python. Python's syntax already allows: >>> m = MyMap() >>> m[K(1, 2, 3, a=4, b=5)] = 'foobar' My idea is to implement this, so that we can better explore the original idea. (In particular, this would allow the idea to be tested in practice, and perhaps acquire a community of users.) For simplicity, assume MyMap = type(m). For >>> m[K(1, 2, 3, a=4, b=5)] = 'foobar' to execute successfully, MyMap must have a __setitem__ method. Aside: Here's an example of failure. >>> True[1] = 2 TypeError: 'bool' object does not support item assignment Let's assume MyMap does have a __setitem__ method. Extending what you pointed out, the assignment >>> m[K(1, 2, 3, a=4, b=5)] = 'foobar' will then be equivalent to >>> MyMap.__setitem__(m, k, 'foobar') where >>> k = K(1, 2, 3, a=4, b=5) The code I wrote, which wasn't clear enough, sketched an adapter between two points of view (although for get rather than set). The basic idea is that >>> MyMap.__setitem__(k, 'foobar') is equivalent to something like >>> func(m, 'foobar', 1, 2, 3, a=4, b=5) where func is defined in the class body of MyMap. Hence the adapter decorator, which is to hide from the author of func many of the details of the implementation of K. I hope this helps. -- Jonathan