develooper Front page | perl.perl5.porters | Postings from October 2011

[perl #101976] [PATCH] Remove cruft from the module example

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
October 23, 2011 12:50
Subject:
[perl #101976] [PATCH] Remove cruft from the module example
Message ID:
rt-3.6.HEAD-31297-1319399430-1252.101976-15-0@perl.org
On Sun Oct 23 04:33:49 2011, ikegami@adaelis.com wrote:
> On Sat, Oct 22, 2011 at 10:42 PM, Michael G Schwern <
> perlbug-followup@perl.org> wrote:
> 
> > # New Ticket Created by  Michael G Schwern
> > # Please include the string:  [perl #101976]
> > # in the subject line of all future correspondence about this issue.
> > # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=101976 >
> >
> > I noticed that the module example in perlmod is a bit long, crufty
and out
> > of
> > date.  I wouldn't teach someone to write a module like that.  It hasn't
> > been
> > seriously touched in about 10 years.  This patch fixes up the most
glaring
> > problems while retaining its utility as a teaching boilerplate.
> >
> > * require Exporter instead of use with no import
> > * Explain what @ISA does.
> > ...
> >
> 
> Instead of changing
> 
>     use Exporter ();
>     @ISA = qw(Exporter);
> 
> to
> 
>     require Exporter;
>     our @ISA = qw(Exporter);
> 
> what about changing it to
> 
>     use Exporter qw( import );

The problem with that is the lack of introspection.  With inheritance,
one can say Class->isa("Exporter") and, if it returns true, read
@EXPORT* and %EXPORT_TAGS to find out what is exported.

Without ->isa("Exporter"), there’s no guarantee that what is in those
variables has anything to do with Exporter.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About