Behavior of the for-else construct

Chris Angelico rosuav at gmail.com
Thu Mar 3 22:23:09 EST 2022


On Fri, 4 Mar 2022 at 14:05, Avi Gross via Python-list
<python-list at python.org> wrote:
> To answer something Chris said and was also mentioned here, I do not consider language design to be easy let alone implementing it. Not at all. BUT I think some changes can be straightforward. Having a symbol like a curly brace mean three new things may be tough to implement. Allowing a new symbol in an expanded set of characters seems more straightforward.
>
> Consider an arrow symbol → pointing to the right and another pointing the other way. Could we add the symbol to the language as a single character, albeit implemented using multiple bytes? If my editor let me insert the darn thing, it might then  be a reasonable use for some construct in the language unique and new. Maybe the language would use the notation to hold objects holding a set and not confuse the notations for sets and dictionaries as Python ended up doing. (Yes, I know it is NOT confusing in some ways as one holds key:value pairs and the other just value, but making an empty set now requires the notation of set() while an empty dictionary is {} right?
>
> So how hard is it for a newly designed language to recognize any use of one arrow and expect everything up to the next arrow (pointing back) to be the contents of a set? It sounds a tad easier than now when Python interpreters have to pause when they see an open bracket and read what follows to see if everything beyond uses dictionary notation before it decides.
>
> But NO, I am not volunteering to do any of that.

That is exactly why (well, one of the reasons why) I recommended going
the whole way and designing a language in full. You will know exactly
how hard it actually is. In fact, "pause when they see an open
bracket" is the least of your worries :)

ChrisA


More information about the Python-list mailing list