Re: Making the for statement work better with nested functions
Hello, On Mon, 30 Nov 2020 12:26:53 +0000 Rob Cliffe <rob.cliffe@btinternet.com> wrote:
On 30/11/2020 08:01, Paul Sokolovsky wrote:
Hello,
On Sun, 29 Nov 2020 18:53:57 -0800 Christopher Barker <pythonchb@gmail.com> wrote:
This is a massively less ambitious idea, and doesn't solve the original problem, but:
I'd like to see a scope for names that are "obviously ;-)" meant to be short lived. At the moment that's the for loop "counters" and those created by context managers:
for i in something: # use i as usual more_code # now i is not defined What other language(s) implement such a scoping discipline? I know of none.
On the other hand, block-scoped variables are implemented in:
* C * C++ * Java * Rust * Lua * JavaScript (not by default, as opt-in) * Scheme * Common Lisp (as opt-in) * ML * Ocaml * Haskell * very long list of other languages...
The aim of the block scoping proposal is to make Python *not worse* than these other languages, instead of adding funny workarounds again.
[]
CHB's proposal may or may not be a good idea. But please treat it on its merits,
Absolutely. I appreciate all the discussion and alternative ideas people put into this. I, on my side, may have a "strong opinion" that ideas I utter are "right", but that doesn't mean I'm not mistaken. These matters really require good consideration from as wider as possible Python community.
instead of saying, as you seem to be, "No other language does this, so it's bound to be a bad idea which will make Python worse".
That's why I try to choose words carefully ;-). I said that if Python does it like many other languages, it definitely won't be worse than them. I said nothing what happens if it doesn't do it like that ;-). All in all, it's just an argument, as anyone else's. But I do think about those matters, I have to admit. And I'd hate yet another advanced Python programmer to leave for Haskell, Go, Rust, Julia, because, from their PoV, Python has a culture of applying workarounds instead of best-practice solutions.
With that attitude, there would never be any innovation in language design.
I'm first to subscribe under that. Recent example: Pattern Matching, a common mantra is "we did it like that because other languages do it like that" (example: https://mail.python.org/archives/list/python-dev@python.org/message/EWX3GWNT...) My response: But did you consider Python's situation? Both "minor" issues, like lack of constants, which requires ugly workarounds, and overall audience of Python? Was the option to use sigils to mark capture (i.e. assignment) targets *really well* considered? They said yes. Ok. Works for me, and I tried to do as much noise as possible to draw other people's attention to that.
Best wishes Rob Cliffe
[] -- Best regards, Paul mailto:pmiscml@gmail.com
participants (1)
-
Paul Sokolovsky