in reply to Re^5: Closures and scope of lexicals
in thread Closures and scope of lexicals

And I added that the consistency isn't 1to1

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^7: Closures and scope of lexicals
by ikegami (Patriarch) on Oct 31, 2024 at 14:39 UTC

    Then you're wrong. The provided code is equivalent to the OP's, and the result is consistent.

      Saying Python's behavior is consistent to Perl's is at best an over simplification and can't be left uncommented.

      JS on the other side is very consistent to Perl, especially when using let

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

        Saying Python's behavior is consistent to Perl's is at best an over simplification and can't be left uncommented.

        Nope, no simplification. Capturing works exactly the same: Variables in scope remain accessible beyond their normal scope.