Bug 7842 - Perl 'indirect object notation' is deprecated, changing to the recommended syntax
Summary: Perl 'indirect object notation' is deprecated, changing to the recommended sy...
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: PC FreeBSD
: P2 normal
Target Milestone: 4.0.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-21 18:36 UTC by Mark Martinec
Modified: 2021-10-17 07:11 UTC (History)
1 user (show)



Attachment Type Modified Status Actions Submitter/CLA Status
avoid indirect object notation (e.g. change: new IO::File() -> IO::File->new) patch None Mark Martinec [HasCLA]
more cases of indirect object notation - in supporting code patch None Mark Martinec [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Martinec 2020-07-21 18:36:24 UTC
Created attachment 5710 [details]
avoid indirect object notation (e.g. change: new IO::File() -> IO::File->new)

https://www.perl.com/article/announcing-perl-7/ :

  At 'The Perl Conference in the Cloud' (2020-07), Sawyer X announced
  that Perl has a new plan moving forward. Work on Perl 7 is already
  underway, but it’s not going to be a huge change in code or syntax.
  It’s Perl 5 with modern defaults and it sets the stage for bigger
  changes later.

https://github.com/Perl/perl5/wiki/Perl7-FAQ


https://www.effectiveperlprogramming.com/2020/06/turn-off-indirect-object-notation/

  Perl v5.32 adds a way to turn off a Perl feature that you shouldn’t
  use anyway. You can still use this feature, but now there’s a way
  to take it away from you. And, with the recent Perl 7 announcement,
  we see why. Eventually Perl wants to get rid of indirect object
  notation [...]


Most of the code in SpamAssassin use the recommended syntax of
method calls, but there are a couple of instances still left
there to use the undesired 'indirect object notation'.

To find these case a 'no feature qw(indirect)' was temporarily
inserted in *.pm and *.raw files right after 'use strict'.
The reported cases were rewritten, the patch is attached.

Unfortunately the 'no feature qw(indirect)' cannot stay in
the code, as it is only available with perl 5.32 and breaks
compatibility with earlier versions.

As this is a purely syntactic style change to match the prevalent
and recommended style of usage, the change does not introduce
any compatibility breakage with old versions of perl, and
tests show no problems - it seems the right thing to do
in view of the upcoming Perl 7.

I haven't touched t/*.t files, as these may require further work.
Also, with Perl7 the bareword filehandles will likely go away,
but this is a subject of another PR.
Comment 1 Mark Martinec 2020-07-21 18:41:49 UTC
trunk:

$ svn ci -m "Bug 7842: Perl 'indirect object notation' is deprecated, changing to the recommended syntax"
Sending        lib/Mail/SpamAssassin/Bayes.pm
Sending        lib/Mail/SpamAssassin/Locker/Flock.pm
Sending        lib/Mail/SpamAssassin/Locker/UnixNFSSafe.pm
Sending        lib/Mail/SpamAssassin/NetSet.pm
Sending        lib/Mail/SpamAssassin/Plugin/OLEVBMacro.pm
Sending        lib/Mail/SpamAssassin/SQLBasedAddrList.pm
Sending        lib/Mail/SpamAssassin/Util.pm
Sending        lib/Mail/SpamAssassin.pm
Sending        sa-check_spamd.raw
Sending        sa-compile.raw
Sending        sa-learn.raw
Sending        sa-update.raw
Sending        spamassassin.raw
Sending        spamd/spamd.raw
Transmitting file data ..............done
Committing transaction...
Committed revision 1880113.
Comment 2 Mark Martinec 2020-08-13 13:19:51 UTC
Created attachment 5716 [details]
more cases of indirect object notation - in supporting code

$ svn ci -m "Bug 7842: Perl 'indirect object notation' is deprecated, changing to the recommended syntax - more cases (in supporting code)"
Sending        build/old/sha1sum.pl
Sending        build/sha256sum.pl
Sending        build/sha512sum.pl
Sending        lib/Mail/SpamAssassin/ArchiveIterator.pm
Sending        lib/Mail/SpamAssassin/BayesStore/PgSQL.pm
Sending        lib/Mail/SpamAssassin/PerMsgLearner.pm
Sending        lib/Mail/SpamAssassin/PerMsgStatus.pm
Sending        masses/corpora/mass-find-nonspam
Sending        masses/mass-check
Sending        spamd-apache2/lib/Mail/SpamAssassin/Spamd/Config.pm
Sending        t/rule_names.t
Sending        t/trust_path.t
Sending        t.rules/run
Sending        tools/split_corpora
Transmitting file data ..............done
Committing transaction...
Committed revision 1880828.
Comment 3 Mark Martinec 2021-10-05 15:55:18 UTC
Objective accomplished (except possibly in tests), closing.
Comment 4 Henrik Krohns 2021-10-17 07:11:58 UTC
Seems PDFInfo had some accidental leftovers in Revision 1893514

Fixed

Sending        trunk/lib/Mail/SpamAssassin/Plugin/PDFInfo.pm
Transmitting file data .done
Committing transaction...
Committed revision 1894307.