On Tue, Jul 14, 2020, at 17:55, Rob Cliffe wrote: > > What if "instead of a special kind of if clause that can only be placed > > after a loop", we simply defined these three special expressions [usable in > > any if/elif statement] to reference special boolean flags that are set > > after exiting any loop? > The problem is: how long would these "special boolean flags" be retained? > Could they still be tested > 100 lines of code later (assuming no other loops were executed)? > After returning from a function? > Inside a new function call? > etc. > This would violate the principle of ... I can't remember the computer > science name for it, but let's call it ... local transparency. > Rob Cliffe
Sorry if this was unclear, but my idea is that they would be per-frame like local variables. Perhaps they could even be implemented *as* local variables, with assign statements emitted during loops by the compiler if they are used anywhere in the function. If that violates 'local transparency', so does using the same scope for ordinary local variables [such as, say, the iteration variable of a for loop, which can also be used 100 lines of code later]. And of course PEP 8 would forbid using them anywhere other than directly after a loop, but allowing them to be used in any if clause prevents you from having two different kinds of compound statement, which can't be mixed together, that both begin with the word "if". _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/D52HTWGHHPBVLQQBYK7O6BDWS6EFSKTF/ Code of Conduct: http://python.org/psf/codeofconduct/