On 19/03/13 02:01, Hrvoje Niksic wrote: > On 03/18/2013 03:23 PM, Chris Angelico wrote: >> The languages that permit you to assign to a function call all have >> some notion of a reference type. > > Assigning to function calls is orthogonal to reference types. For example, Python manages assignment to subscripts without having references just fine: > > val = obj[index] # val = obj.__getitem__(index) > obj[index] = val # obj.__setitem__(index, val) > > In analogy with that, Python could implement what looks like assignment to function call like this: > > val = f(arg) # val = f.__call__(arg) > f(arg) = val # f.__setcall__(arg, val) That's all very well, but what would it do? It's not enough to say that the syntax could exist, we also need to have semantics. What's the use-case here? (That question is mostly aimed at the original poster.) Aside: I'd reverse the order of the arg, val in any such hypothetical __setcall__, so as to support functions with zero or more arguments: f(*args, **kwargs) = val <=> f.__setcall__(val, *args, **kwargs) -- Steven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4