New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize Exporter usage in perlmod #16879
Comments
From @Grinnzperlmod contains a "module template" which shows outdated usage of the -Dan (Perl) |
From @GrinnzPatch is attached. |
From @Grinnz0001-modernize-Exporter-usage-in-perlmod-module-template.patchFrom 8bae8c75e89dc50c6bd1ef0e36795626b6bdc009 Mon Sep 17 00:00:00 2001
From: Dan Book <grinnz@grinnz.com>
Date: Thu, 7 Mar 2019 19:34:14 -0500
Subject: [PATCH] modernize Exporter usage in perlmod module template
---
pod/perlmod.pod | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/pod/perlmod.pod b/pod/perlmod.pod
index c87a68d837..ffabe94b5d 100644
--- a/pod/perlmod.pod
+++ b/pod/perlmod.pod
@@ -447,21 +447,17 @@ create a file called F<Some/Module.pm> and start with this template:
use strict;
use warnings;
- BEGIN {
- require Exporter;
+ # Get the import method from Exporter to export functions and variables
+ use Exporter 'import';
- # set the version for version checking
- our $VERSION = 1.00;
+ # set the version for version checking
+ our $VERSION = 1.00;
- # Inherit from Exporter to export functions and variables
- our @ISA = qw(Exporter);
+ # Functions and variables which are exported by default
+ our @EXPORT = qw(func1 func2);
- # Functions and variables which are exported by default
- our @EXPORT = qw(func1 func2);
-
- # Functions and variables which can be optionally exported
- our @EXPORT_OK = qw($Var1 %Hashit func3);
- }
+ # Functions and variables which can be optionally exported
+ our @EXPORT_OK = qw($Var1 %Hashit func3);
# exported package globals go here
our $Var1 = '';
@@ -487,7 +483,7 @@ create a file called F<Some/Module.pm> and start with this template:
sub func1 { ... }
sub func2 { ... }
- # this one isn't exported, but could be called directly
+ # this one isn't always exported, but could be called directly
# as Some::Module::func3()
sub func3 { ... }
--
2.20.1
|
From @GrinnzUpdated patch. Additionally changes the version declaration to be a string. |
From @Grinnz0001-modernize-Exporter-usage-in-perlmod-module-template.patchFrom 0e175824dce34de2853b69e1c4e5cccb2924e187 Mon Sep 17 00:00:00 2001
From: Dan Book <grinnz@grinnz.com>
Date: Thu, 7 Mar 2019 19:34:14 -0500
Subject: [PATCH] modernize Exporter usage in perlmod module template
---
pod/perlmod.pod | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/pod/perlmod.pod b/pod/perlmod.pod
index c87a68d837..64d5fdd81a 100644
--- a/pod/perlmod.pod
+++ b/pod/perlmod.pod
@@ -447,21 +447,17 @@ create a file called F<Some/Module.pm> and start with this template:
use strict;
use warnings;
- BEGIN {
- require Exporter;
+ # Get the import method from Exporter to export functions and variables
+ use Exporter 'import';
- # set the version for version checking
- our $VERSION = 1.00;
+ # set the version for version checking
+ our $VERSION = '1.00';
- # Inherit from Exporter to export functions and variables
- our @ISA = qw(Exporter);
+ # Functions and variables which are exported by default
+ our @EXPORT = qw(func1 func2);
- # Functions and variables which are exported by default
- our @EXPORT = qw(func1 func2);
-
- # Functions and variables which can be optionally exported
- our @EXPORT_OK = qw($Var1 %Hashit func3);
- }
+ # Functions and variables which can be optionally exported
+ our @EXPORT_OK = qw($Var1 %Hashit func3);
# exported package globals go here
our $Var1 = '';
@@ -487,7 +483,7 @@ create a file called F<Some/Module.pm> and start with this template:
sub func1 { ... }
sub func2 { ... }
- # this one isn't exported, but could be called directly
+ # this one isn't always exported, but could be called directly
# as Some::Module::func3()
sub func3 { ... }
--
2.20.1
|
From @jkeenanOn Fri, 08 Mar 2019 00:42:30 GMT, grinnz@gmail.com wrote:
+1 -- |
The RT System itself - Status changed from 'new' to 'open' |
From @LeontOn Fri, Mar 8, 2019 at 1:43 AM Dan Book via RT
Importing Exporter::import requires Exporter 5.57, I would make that Leon |
From @xenuOn Fri, 8 Mar 2019 14:32:16 +0100
Which was released billion years ago. Perl 5.8.3 was the first perl to IMO at this point this information is a historical trivia and it doesn't |
From Vadim.Konovalov@dell.com
then perl is so ancient that it have no chances to modernize, ever!. Observe: perldoc perlvar ... Since Perl v5.6.0, Perl variable names may also be alphanumeric strings preceded by a caret. These must all be ... what is this? 5.8.3 is billion years? but documentation cares of 5.6.0?? maaaan, need to switch to modern something! |
From @TuxOn Sat, 9 Mar 2019 13:31:18 +0000, "Konovalov, Vadim" <Vadim.Konovalov@dell.com> wrote:
$ perldoc perlhist will show you 5.8.3 2004-Jan-14 Diff : 5533 days (15 y, 1 m, 23 d)
5.6.0 2000-Mar-22 Diff : 6926 days (18 y, 11 m, 15 d)
perl *is* modern, but - in contradiction with some other languages - There is no harm whatsoever in mentioning in the docs why the current So, with that in mind, can you tell me why it hurts you to be explicit Being specific in what you require does not slow down the process, it Maybe you also use C++-style comments instead of ANSI-C style comments, FWIW, unless it really hinders my development, I still try to support If you want to switch to something more modern, switch to perl-5.28.1 -- |
From @GrinnzThis is not reference documentation. This is a tutorial for how to write new modules, and displays a template which is highly likely to be copy pasted around without further inspection. Any extraneous information is likely to be ignored or cause further confusion. I would consider the exporting of non-sub variables to be extraneous as well in the context of what new module writers need, but that is out of the scope of this patch. If a user wants to support ancient Perls, they can read the linked docs for Exporter to determine how to do so. -Dan |
From Vadim.Konovalov@dell.com
q.e.d.
this is so, I agree.
In current IT standards they will say to you that old versions are vulnerable to hacker attacks
It occupies 2 expensive things: engineer's time on reading this documentation and However I raised this problem, couple of times, couple of years ago, so returning not a big deal, anyway
It does slow down, strictly speaking. It could be that slowing down the process is so small Vadim |
From @xsawyerxOn 3/8/19 3:32 PM, Leon Timmermans wrote:
From my perspective, there are several alternatives, of which I don't 1. Update it to `use Exporter 5.57;` and be done with it. 2. Update it to `use Exporter;` and the line below would be something 2. Don't update it to 5.57, but write a paragraph underneath saying 3. Don't update it to 5.57, but include a small sentence saying "This The argument here is simple: * Short, clear examples are easier to read and understand. * Do not optimize for *all* use-cases, but for the most common ones. * If you're using something old enough[1] that does not carry this * You can always find the old documentation that came with your Perl and * The only argument here against the patch falls into "don't do it," Theoretically, we would like our documentation to reflect the supported S. [1] Without going into the argument of "this is ancient" or what the |
From @demerphqOn Mon, 8 Apr 2019 at 07:47, Sawyer X <xsawyerx@gmail.com> wrote:
There are two definitions of "billion". Which one did you not want to Yves -- |
From @GrinnzUpdated patch attached. I chose option 1 (use Exporter 5.57) for the sake of avoiding the distraction of explaining backcompat here, it creates a readable error message, and it allows auto-prereqs heuristics to add the proper version requirement. |
From @Grinnz0001-modernize-Exporter-usage-in-perlmod-module-template.patchFrom 9f5c03fbc29396bc6959755b721b09c61e02aea3 Mon Sep 17 00:00:00 2001
From: Dan Book <grinnz@grinnz.com>
Date: Thu, 7 Mar 2019 19:34:14 -0500
Subject: [PATCH] modernize Exporter usage in perlmod module template
---
pod/perlmod.pod | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/pod/perlmod.pod b/pod/perlmod.pod
index c87a68d837..23351cbdf2 100644
--- a/pod/perlmod.pod
+++ b/pod/perlmod.pod
@@ -447,21 +447,17 @@ create a file called F<Some/Module.pm> and start with this template:
use strict;
use warnings;
- BEGIN {
- require Exporter;
+ # Get the import method from Exporter to export functions and variables
+ use Exporter 5.57 'import';
- # set the version for version checking
- our $VERSION = 1.00;
+ # set the version for version checking
+ our $VERSION = '1.00';
- # Inherit from Exporter to export functions and variables
- our @ISA = qw(Exporter);
+ # Functions and variables which are exported by default
+ our @EXPORT = qw(func1 func2);
- # Functions and variables which are exported by default
- our @EXPORT = qw(func1 func2);
-
- # Functions and variables which can be optionally exported
- our @EXPORT_OK = qw($Var1 %Hashit func3);
- }
+ # Functions and variables which can be optionally exported
+ our @EXPORT_OK = qw($Var1 %Hashit func3);
# exported package globals go here
our $Var1 = '';
@@ -487,7 +483,7 @@ create a file called F<Some/Module.pm> and start with this template:
sub func1 { ... }
sub func2 { ... }
- # this one isn't exported, but could be called directly
+ # this one isn't always exported, but could be called directly
# as Some::Module::func3()
sub func3 { ... }
--
2.20.1
|
From @xsawyerxA +1 from me. Thank you for doing this. We need more of it. On 4/9/19 1:28 AM, Dan Book via RT wrote:
|
From @xsawyerxOn 4/9/19 1:13 AM, demerphq wrote:
Neither. (Or is it "neither"?) |
From @tonycozOn Mon, 08 Apr 2019 15:28:17 -0700, grinnz@gmail.com wrote:
Thanks, applied as b634e87. I had to wrap the: # Get the import method from Exporter to export functions and variables line as podcheck complained. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133909 (status was 'resolved')
Searchable as RT133909$
The text was updated successfully, but these errors were encountered: