Skip Menu |

This queue is for tickets about the ExtUtils-ModuleMaker CPAN distribution.

Report information
The Basics
Id: 8459
Status: resolved
Worked: 10 min
Priority: 0/
Queue: ExtUtils-ModuleMaker

People
Owner: jkeenan [...] cpan.org
Requestors: william [...] knowmad.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.32
Fixed in: (no value)



Subject: Stub code overrides use base pragmas
Hi Geoffrey, Thanks for the great module. I've been using it to setup my projects using Module::Build. Recently I came across a problem in my code that relates to the template that modulemaker uses in an empty module. The BEGIN block has the following line: @ISA = qw (Exporter); This works fine unless @ISA is redefined elsewhere via a similar line or, less obvious to programmers who are new to writing modules, via the 'use base' pragma. I was able to change that line to the following version which works with 'use base': push @ISA, qw (Exporter); Unless there is something wrong with the above line, I think it'd be a good thing to use it instead of the existing format. Hopefully it will save others the time I just spent debugging my new module. Thanks, William
I've taken over maintenance of this module from Geoff Avery; see v0.36 on CPAN. I'm not accepting your patch at this time, but may do so in the future. We're doing a lot of thinking about how to make EU::MM more easily subclassable. That will affect @ISA. So I'll take your suggestion under advisement and see how things work out. Thanks.
[guest - Tue Nov 16 08:55:05 2004]: Show quoted text
> Hi Geoffrey, > > Thanks for the great module. I've been using it to setup my projects > using Module::Build. Recently I came across a problem in my code > that relates to the template that modulemaker uses in an empty > module. > > The BEGIN block has the following line: > > @ISA = qw (Exporter); > > This works fine unless @ISA is redefined elsewhere via a similar line > or, less obvious to programmers who are new to writing modules, via > the 'use base' pragma. I was able to change that line to the > following version which works with 'use base': > > push @ISA, qw (Exporter); > > Unless there is something wrong with the above line, I think it'd be a > good thing to use it instead of the existing format. Hopefully it > will save others the time I just spent debugging my new module. >
As noted previously, I, Jim Keenan, have taken over maintenance of ExtUtils::ModuleMaker. Tonight I uploaded to CPAN v0.42, along with v0.07 of its subclass, ExtUtils::ModuleMaker:: PBP. This latest version will, I believe, correct all the bugs previously reported for EU::MM as well as make significant enhancements to its flexibility. With one caveat, I'm going to reject your suggestion because I think it fundamentally misunderstands the difference between functional and object-oriented programming in Perl. If you write a package from which you intend to export subroutines for use in other Perl packages, you need a mechanism to export those subroutines and enable the other packages to import them. 99% of the time, you don't need to write your own import() routine; you simply declare that your package inherits from Exporter -- specifically, it inherits Exporter:: import(). With object-oriented Perl, your packages hold those special subroutines known as methods. These are *not* exported. Once you construct a new object of a particular class, you get the data wrapped up in that object plus the methods you can call on it. Often, you want to allow your package to inherit methods from some other package. That's the circumstance in which you would use 'use base'. So, in my understanding, I would never expect to see either 'push @ISA, qw (Exporter);' or '@ISA = qw (Exporter);' in an object-oriented Perl module. Hence, I don't see the need to revise EU::MM's default lib/*.pm file content to accommodate your request. But what about that caveat I mentioned earlier? Well, the advantage of the new version of ExtUtils::ModuleMaker is that it makes it easier (or, at least, easier) to subclass EU::MM for the purpose of including your own boilerplate text in the files in your new distribution. See the documentation and, for a live example, see my other new CPAN distribution, ExtUtils:: ModuleMaker::PBP, where I modify EU::MM so as to create the skeleton for a Perl distribution in the style recommended by Damian Conway's "Perl Best Practices." In short, you're free -- indeed, encouraged, to subclass EU::MM to have it just the way you want it. I should add that the boilerplate code and text found in the files created by EU::MM's default settings is not necessarily the way I myself would code. But, as a maintenance programmer, I felt it was important not to change Geoff Avery's default settings unless absolutely necessary, because there may be programmers out there quite happy with those settings who would not like to see them superseded in a new version of the module. Please let me know how you find the latest version. Thank you very much. Jim Keenan