On Tue, Apr 18, 2006 at 09:41:20PM -0400, Edward C. Jones wrote:
> Wild idea.
> 
> When I was a newbie, I repeatedly make the mistake of writing
> 
> alist = alist.sort()
> 
> I suggest a singleton object "UseForbidden" ("Py_UseForbidden" in C). 
> "UseForbidden" can be used only to return from a function. Any other 
> attempt to use "UseForbidden" raises an exception. The incorrect code 
> above would give the error message "cannot assign to result of function".

Not to beat the horse a bit further, but...

This would also have the unfortunate side affect of forbidding 
snippets like-

groupped_lists = generate_list_of_lists()
[l.sort() for l in groupped_lists]

Yes, it's lazy (could use a for loop doesn't generate a list), but the 
short hand there is common enough, as is the map equiv.

Rough guess, to properly handle above (ie, support it while 
disallowing assignment to vars) requires tracing back the 
assignment- no longer is it just "am I assigning to a var", it's now 
"am I being handed to a var that is going to go away immediately" 
which is far uglier/nastier.

My interpretation at least, either way -1 (especially if it kills off 
the short hand) :)
~harring

Attachment: pgpU75uI7QnQv.pgp
Description: PGP signature

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to