in reply to Re^3: Opinion: where Perl5 wasn't attractive for me
in thread Opinion: where Perl5 wasn't attractive for me

The now appended example demonstrates a case where (like mentioned before) block scoping matters.

Python has no blockscoping, such that the second assignment is not considered an declaration cause the variable has already been intialized in the "wider" scope (file or function)

Perl has blockscoping such that a command like nonlocal would be needed far too often ... or more "headache" (sic) would be needed figure out a workaround.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

Replies are listed 'Best First'.
Re^5: Opinion: where Perl5 wasn't attractive for me
by SuicideJunkie (Vicar) on Nov 19, 2014 at 18:57 UTC

    Considering that this is a question of adding the 'feature' to Perl, the fact that Python doesn't have block scoping doesn't really factor into it.

    Also, note that the second assignment is a typo, and IS actually the first (and only) instance of that specific variable name. (I've added a comment to point it out)

      You're getting it wrong ... comparing and learning from experiences other language designers made is helpful.

      If someone says declaration should work like in Ruby or Python it's valuable to show that those languages pay a prize for it.

      And I don't wanna miss block scope...

      Though I don't see a reason to apologize now... If you are not interested in comparing design, ignore me. :)

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

        Two sides of the same coin I suppose.

        "Can't just add this to perl because it will break things." vs "In order to add this without breaking things, you need to remove core features."

        I'm not sure what you would have to apologize for... I'm pretty sure we are arguing the same thing from different perspectives.

        Now I'm thinking it is like a Language of Theseus. How may core features do you swap out before it is no longer perl? ;)

Re^5: Opinion: where Perl5 wasn't attractive for me
by Jenda (Abbot) on Nov 20, 2014 at 16:11 UTC

    Unless Python also requires that all variable initializations happen before any other statements in a method/function, its lack of block scoping is absolutely irrelevant. It doesn't matter whether the scope of $faultsInaRow is the block, the loop or the method. It should have been caught as a typo, because it was not mean as an initialization. It should have been merely an assignment.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.