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

That is what Python2+ does (autodeclaring at first assignment), with side effects on closures, which forced Guido to introduce 'nonlocal' in Python3.

Apart from this does Python not use blockscoping¹ (IIRC) like Perl does, but only function scoping, so far less edge cases to be considered.

I wouldn't say an automine pragma would be necessarily bad, but it would cause considerable headaches to avoid incompatibilities and extra thoughts to catch typos blowing up at runtime.

Cheers Rolf

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

¹) i.e. block in the sense of e.g. the body of a loop

Replies are listed 'Best First'.
Re^4: Opinion: where Perl5 wasn't attractive for me
by RonW (Parson) on Nov 19, 2014 at 20:25 UTC

    I think that, in Perl, an automine pragma would be very confusing. Currently, in the absence of strict, Perl auto-declares variables as package (aka our) variables on first use. An automine pragma would turn that on its side by auto-declaring them as local1 (aka my) variables.

    Whatever the merits of defaulting variables to local scope might be, doing so in Perl would likely be too confusing.

    ---

    1 as in "local scope", not "localized package variables".

      I don't expect anyone to implement it ...

      And it's far more complicated than use vars cause scoping and closures come into play.

      At best an IDE might help auto expanding my.

      Anyway I'll better stop now feeding this thread =)

      Cheers Rolf

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