http://qs321.pair.com?node_id=506973


in reply to Writing for backwards compatibility

Speaking as someone who is (at least currently) tethered to 5.005_03, I've got to speak up for how utterly annoying it is to find modules out there that needlessly use fairly pointless new features (specifically our, but also, to a certain extent use/no warnings).

Don't get me wrong, lexical filehandles and 3-arg open are hugely nice, and I can't really argue with that. But how many modules out there just use our for no reason whatsoever, other than to force perl 5.5ers to have to edit the module before using it?

------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re^2: Writing for backwards compatibility
by xdg (Monsignor) on Nov 09, 2005 at 11:51 UTC

    I think 'our' is often used to avoid having to type 'use vars', but I recently saw a module on CPAN with a surprisingly obvious way of avoiding it. (strict police may want to avoid reading further.)

    package My::Module; $VERSION = 1.23; @ISA = 'Exporter'; @EXPORT = qw( wibble wobble ); use strict; use warnings; use Exporter; # rest of module ...

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      Also, the third edition of Programming Perl describes the vars pragma as "somewhat deprecated". Current Perl docs don't label it that way...

      --
      Marvin Humphrey
      Rectangular Research ― http://www.rectangular.com
Re^2: Writing for backwards compatibility
by mirod (Canon) on Nov 09, 2005 at 09:33 UTC

    When that happens, do you report test failures (using cpantest, provided by Test::Reporter)? If you do, I am pretty sure most authors will gladdly fix the code. Especially if you also include the patch. I am sure most authors do not willingly break compatibility, it just happens, sometimes for good reasons (unicode), sometimes just by habit or oversight.

Re^2: Writing for backwards compatibility
by adrianh (Chancellor) on Nov 09, 2005 at 12:25 UTC
    But how many modules out there just use our for no reason whatsoever, other than to force perl 5.5ers to have to edit the module before using it?

    I don't use our for no reason. I use it because I find it clearer and I have to type less.

    Unfortunately my priorities (typing less) do not match your priorities (working code on 5.005_3) :-)