A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-August/068153.html below:

[Python-Dev] SyntaxError: can't assign to function call

[Python-Dev] SyntaxError: can't assign to function callJames Y Knight foom at fuhm.net
Fri Aug 11 06:53:41 CEST 2006
On Aug 10, 2006, at 4:57 PM, Phillip J. Eby wrote:

> However, I'm also not clear that trying to assign to a function  
> call *is* ill-advised.  One of the things that attracted me to  
> Python in the first place is that it had a lot of features that  
> would be considered "hypergeneralization" in other languages, e.g.  
> the ability to create your own sequences, mappings, and callable  
> objects in the first place.
>
> That being said, the benefit of hypergeneralizing assignment seems  
> small compared to its price.

Well, it's a mostly obvious extension of an existing idea, so the  
price doesn't seem all that high. The main problem is that so far,  
there have been 0 convincing use cases. So no matter how moderate the  
price, it's definitely bigger than the benefit. But anyhow, speaking  
of hypergeneralization...since this has 0 use cases anyhow, might as  
well hyperhypergeneralize it...

Well, why should assignment be limited to only local variables, item  
access, and function calls. Why shouldn't you be able to potentially  
assign to _any_ expression!

Since
x + a turns into (very roughly...) x.__add__(a),

then,
x + a = 5 could turn into x.__add__.__setcall__(5, a).

Of course, since normal __add__ functions don't have a __setcall__,  
doing this will raise an error. But, a user defined __add__ could  
have one! And what would such a user defined __add__.__setcall__  
actually *do*? Well, that would be a use case, and I sure don't have  
any of those!

Ta Da. Who's going to make the patch? ;)

James
More information about the Python-Dev mailing list

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