Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / Class::Accessor.3pm
diff --git a/local-lib5/man/man3/Class::Accessor.3pm b/local-lib5/man/man3/Class::Accessor.3pm
new file mode 100644 (file)
index 0000000..20a683e
--- /dev/null
@@ -0,0 +1,727 @@
+.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sh \" Subsection heading
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  | will give a
+.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
+.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
+.\" expand to `' in nroff, nothing in troff, for use with C<>.
+.tr \(*W-|\(bv\*(Tr
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.if \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.\"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.hy 0
+.if n .na
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "Class::Accessor 3"
+.TH Class::Accessor 3 "2009-09-15" "perl v5.8.7" "User Contributed Perl Documentation"
+.SH "NAME"
+.Vb 1
+\&  Class::Accessor \- Automated accessor generation
+.Ve
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+.Vb 4
+\&  package Foo;
+\&  use base qw(Class::Accessor);
+\&  Foo\->follow_best_practice;
+\&  Foo\->mk_accessors(qw(name role salary));
+.Ve
+.PP
+.Vb 1
+\&  # or if you prefer a Moose\-like interface...
+.Ve
+.PP
+.Vb 5
+\&  package Foo;
+\&  use Class::Accessor "antlers";
+\&  has name => ( is => "rw", isa => "Str" );
+\&  has role => ( is => "rw", isa => "Str" );
+\&  has salary => ( is => "rw", isa => "Num" );
+.Ve
+.PP
+.Vb 3
+\&  # Meanwhile, in a nearby piece of code!
+\&  # Class::Accessor provides new().
+\&  my $mp = Foo\->new({ name => "Marty", role => "JAPH" });
+.Ve
+.PP
+.Vb 2
+\&  my $job = $mp\->role;  # gets $mp\->{role}
+\&  $mp\->salary(400000);  # sets $mp\->{salary} = 400000 # I wish
+.Ve
+.PP
+.Vb 2
+\&  # like my @info = @{$mp}{qw(name role)}
+\&  my @info = $mp\->get(qw(name role));
+.Ve
+.PP
+.Vb 2
+\&  # $mp\->{salary} = 400000
+\&  $mp\->set('salary', 400000);
+.Ve
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+This module automagically generates accessors/mutators for your class.
+.PP
+Most of the time, writing accessors is an exercise in cutting and
+pasting.  You usually wind up with a series of methods like this:
+.PP
+.Vb 7
+\&    sub name {
+\&        my $self = shift;
+\&        if(@_) {
+\&            $self\->{name} = $_[0];
+\&        }
+\&        return $self\->{name};
+\&    }
+.Ve
+.PP
+.Vb 7
+\&    sub salary {
+\&        my $self = shift;
+\&        if(@_) {
+\&            $self\->{salary} = $_[0];
+\&        }
+\&        return $self\->{salary};
+\&    }
+.Ve
+.PP
+.Vb 1
+\&  # etc...
+.Ve
+.PP
+One for each piece of data in your object.  While some will be unique,
+doing value checks and special storage tricks, most will simply be
+exercises in repetition.  Not only is it Bad Style to have a bunch of
+repetitious code, but it's also simply not lazy, which is the real
+tragedy.
+.PP
+If you make your module a subclass of Class::Accessor and declare your
+accessor fields with \fImk_accessors()\fR then you'll find yourself with a
+set of automatically generated accessors which can even be
+customized!
+.PP
+The basic set up is very simple:
+.PP
+.Vb 3
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->mk_accessors( qw(far bar car) );
+.Ve
+.PP
+Done.  Foo now has simple \fIfar()\fR, \fIbar()\fR and \fIcar()\fR accessors
+defined.
+.PP
+Alternatively, if you want to follow Damian's \fIbest practice\fR guidelines 
+you can use:
+.PP
+.Vb 4
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->follow_best_practice;
+\&    Foo\->mk_accessors( qw(far bar car) );
+.Ve
+.PP
+\&\fBNote:\fR you must call \f(CW\*(C`follow_best_practice\*(C'\fR before calling \f(CW\*(C`mk_accessors\*(C'\fR.
+.Sh "Moose-like"
+.IX Subsection "Moose-like"
+By popular demand we now have a simple Moose-like interface.  You can now do:
+.PP
+.Vb 5
+\&    package Foo;
+\&    use Class::Accessor "antlers";
+\&    has far => ( is => "rw" );
+\&    has bar => ( is => "rw" );
+\&    has car => ( is => "rw" );
+.Ve
+.PP
+Currently only the \f(CW\*(C`is\*(C'\fR attribute is supported.
+.SH "CONSTRUCTOR"
+.IX Header "CONSTRUCTOR"
+Class::Accessor provides a basic constructor, \f(CW\*(C`new\*(C'\fR.  It generates a
+hash-based object and can be called as either a class method or an
+object method.  
+.Sh "new"
+.IX Subsection "new"
+.Vb 2
+\&    my $obj = Foo\->new;
+\&    my $obj = $other_obj\->new;
+.Ve
+.PP
+.Vb 2
+\&    my $obj = Foo\->new(\e%fields);
+\&    my $obj = $other_obj\->new(\e%fields);
+.Ve
+.PP
+It takes an optional \f(CW%fields\fR hash which is used to initialize the
+object (handy if you use read-only accessors).  The fields of the hash
+correspond to the names of your accessors, so...
+.PP
+.Vb 3
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->mk_accessors('foo');
+.Ve
+.PP
+.Vb 2
+\&    my $obj = Foo\->new({ foo => 42 });
+\&    print $obj\->foo;    # 42
+.Ve
+.PP
+however \f(CW%fields\fR can contain anything, \fInew()\fR will shove them all into
+your object.
+.SH "MAKING ACCESSORS"
+.IX Header "MAKING ACCESSORS"
+.Sh "follow_best_practice"
+.IX Subsection "follow_best_practice"
+In Damian's Perl Best Practices book he recommends separate get and set methods
+with the prefix set_ and get_ to make it explicit what you intend to do.  If you
+want to create those accessor methods instead of the default ones, call:
+.PP
+.Vb 1
+\&    __PACKAGE__\->follow_best_practice
+.Ve
+.PP
+\&\fBbefore\fR you call any of the accessor-making methods.
+.Sh "accessor_name_for / mutator_name_for"
+.IX Subsection "accessor_name_for / mutator_name_for"
+You may have your own crazy ideas for the names of the accessors, so you can
+make those happen by overriding \f(CW\*(C`accessor_name_for\*(C'\fR and \f(CW\*(C`mutator_name_for\*(C'\fR in
+your subclass.  (I copied that idea from Class::DBI.)
+.Sh "mk_accessors"
+.IX Subsection "mk_accessors"
+.Vb 1
+\&    __PACKAGE__\->mk_accessors(@fields);
+.Ve
+.PP
+This creates accessor/mutator methods for each named field given in
+\&\f(CW@fields\fR.  Foreach field in \f(CW@fields\fR it will generate two accessors.
+One called \*(L"\fIfield()\fR\*(R" and the other called \*(L"\fI_field_accessor()\fR\*(R".  For
+example:
+.PP
+.Vb 2
+\&    # Generates foo(), _foo_accessor(), bar() and _bar_accessor().
+\&    __PACKAGE__\->mk_accessors(qw(foo bar));
+.Ve
+.PP
+See \*(L"Overriding autogenerated accessors\*(R" in \s-1CAVEATS\s0 \s-1AND\s0 \s-1TRICKS\s0
+for details.
+.Sh "mk_ro_accessors"
+.IX Subsection "mk_ro_accessors"
+.Vb 1
+\&  __PACKAGE__\->mk_ro_accessors(@read_only_fields);
+.Ve
+.PP
+Same as \fImk_accessors()\fR except it will generate read-only accessors
+(ie. true accessors).  If you attempt to set a value with these
+accessors it will throw an exception.  It only uses \fIget()\fR and not
+\&\fIset()\fR.
+.PP
+.Vb 3
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->mk_ro_accessors(qw(foo bar));
+.Ve
+.PP
+.Vb 3
+\&    # Let's assume we have an object $foo of class Foo...
+\&    print $foo\->foo;  # ok, prints whatever the value of $foo\->{foo} is
+\&    $foo\->foo(42);    # BOOM!  Naughty you.
+.Ve
+.Sh "mk_wo_accessors"
+.IX Subsection "mk_wo_accessors"
+.Vb 1
+\&  __PACKAGE__\->mk_wo_accessors(@write_only_fields);
+.Ve
+.PP
+Same as \fImk_accessors()\fR except it will generate write-only accessors
+(ie. mutators).  If you attempt to read a value with these accessors
+it will throw an exception.  It only uses \fIset()\fR and not \fIget()\fR.
+.PP
+\&\fB\s-1NOTE\s0\fR I'm not entirely sure why this is useful, but I'm sure someone
+will need it.  If you've found a use, let me know.  Right now it's here
+for orthoginality and because it's easy to implement.
+.PP
+.Vb 3
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->mk_wo_accessors(qw(foo bar));
+.Ve
+.PP
+.Vb 3
+\&    # Let's assume we have an object $foo of class Foo...
+\&    $foo\->foo(42);      # OK.  Sets $self\->{foo} = 42
+\&    print $foo\->foo;    # BOOM!  Can't read from this accessor.
+.Ve
+.SH "Moose!"
+.IX Header "Moose!"
+If you prefer a Moose-like interface to create accessors, you can use \f(CW\*(C`has\*(C'\fR by
+importing this module like this:
+.PP
+.Vb 1
+\&  use Class::Accessor "antlers";
+.Ve
+.PP
+or
+.PP
+.Vb 1
+\&  use Class::Accessor "moose\-like";
+.Ve
+.PP
+Then you can declare accessors like this:
+.PP
+.Vb 3
+\&  has alpha => ( is => "rw", isa => "Str" );
+\&  has beta  => ( is => "ro", isa => "Str" );
+\&  has gamma => ( is => "wo", isa => "Str" );
+.Ve
+.PP
+Currently only the \f(CW\*(C`is\*(C'\fR attribute is supported.  And our \f(CW\*(C`is\*(C'\fR also supports
+the \*(L"wo\*(R" value to make a write-only accessor.
+.PP
+If you are using the Moose-like interface then you should use the \f(CW\*(C`extends\*(C'\fR
+rather than tweaking your \f(CW@ISA\fR directly.  Basically, replace
+.PP
+.Vb 1
+\&  @ISA = qw/Foo Bar/;
+.Ve
+.PP
+with
+.PP
+.Vb 1
+\&  extends(qw/Foo Bar/);
+.Ve
+.SH "DETAILS"
+.IX Header "DETAILS"
+An accessor generated by Class::Accessor looks something like
+this:
+.PP
+.Vb 10
+\&    # Your foo may vary.
+\&    sub foo {
+\&        my($self) = shift;
+\&        if(@_) {    # set
+\&            return $self\->set('foo', @_);
+\&        }
+\&        else {
+\&            return $self\->get('foo');
+\&        }
+\&    }
+.Ve
+.PP
+Very simple.  All it does is determine if you're wanting to set a
+value or get a value and calls the appropriate method.
+Class::Accessor provides default \fIget()\fR and \fIset()\fR methods which
+your class can override.  They're detailed later.
+.Sh "Modifying the behavior of the accessor"
+.IX Subsection "Modifying the behavior of the accessor"
+Rather than actually modifying the accessor itself, it is much more
+sensible to simply override the two key methods which the accessor
+calls.  Namely \fIset()\fR and \fIget()\fR.
+.PP
+If you \-really\- want to, you can override \fImake_accessor()\fR.
+.Sh "set"
+.IX Subsection "set"
+.Vb 2
+\&    $obj\->set($key, $value);
+\&    $obj\->set($key, @values);
+.Ve
+.PP
+\&\fIset()\fR defines how generally one stores data in the object.
+.PP
+override this method to change how data is stored by your accessors.
+.Sh "get"
+.IX Subsection "get"
+.Vb 2
+\&    $value  = $obj\->get($key);
+\&    @values = $obj\->get(@keys);
+.Ve
+.PP
+\&\fIget()\fR defines how data is retreived from your objects.
+.PP
+override this method to change how it is retreived.
+.Sh "make_accessor"
+.IX Subsection "make_accessor"
+.Vb 1
+\&    $accessor = __PACKAGE__\->make_accessor($field);
+.Ve
+.PP
+Generates a subroutine reference which acts as an accessor for the given
+\&\f(CW$field\fR.  It calls \fIget()\fR and \fIset()\fR.
+.PP
+If you wish to change the behavior of your accessors, try overriding
+\&\fIget()\fR and \fIset()\fR before you start mucking with \fImake_accessor()\fR.
+.Sh "make_ro_accessor"
+.IX Subsection "make_ro_accessor"
+.Vb 1
+\&    $read_only_accessor = __PACKAGE__\->make_ro_accessor($field);
+.Ve
+.PP
+Generates a subroutine refrence which acts as a read-only accessor for
+the given \f(CW$field\fR.  It only calls \fIget()\fR.
+.PP
+Override \fIget()\fR to change the behavior of your accessors.
+.Sh "make_wo_accessor"
+.IX Subsection "make_wo_accessor"
+.Vb 1
+\&    $read_only_accessor = __PACKAGE__\->make_wo_accessor($field);
+.Ve
+.PP
+Generates a subroutine refrence which acts as a write-only accessor
+(mutator) for the given \f(CW$field\fR.  It only calls \fIset()\fR.
+.PP
+Override \fIset()\fR to change the behavior of your accessors.
+.SH "EXCEPTIONS"
+.IX Header "EXCEPTIONS"
+If something goes wrong Class::Accessor will warn or die by calling Carp::carp
+or Carp::croak.  If you don't like this you can override \fI_carp()\fR and \fI_croak()\fR in
+your subclass and do whatever else you want.
+.SH "EFFICIENCY"
+.IX Header "EFFICIENCY"
+Class::Accessor does not employ an autoloader, thus it is much faster
+than you'd think.  Its generated methods incur no special penalty over
+ones you'd write yourself.
+.PP
+.Vb 6
+\&  accessors:
+\&              Rate  Basic   Fast Faster Direct
+\&  Basic   367589/s     \-\-   \-51%   \-55%   \-89%
+\&  Fast    747964/s   103%     \-\-    \-9%   \-77%
+\&  Faster  819199/s   123%    10%     \-\-   \-75%
+\&  Direct 3245887/s   783%   334%   296%     \-\-
+.Ve
+.PP
+.Vb 6
+\&  mutators:
+\&              Rate    Acc   Fast Faster Direct
+\&  Acc     265564/s     \-\-   \-54%   \-63%   \-91%
+\&  Fast    573439/s   116%     \-\-   \-21%   \-80%
+\&  Faster  724710/s   173%    26%     \-\-   \-75%
+\&  Direct 2860979/s   977%   399%   295%     \-\-
+.Ve
+.PP
+Class::Accessor::Fast is faster than methods written by an average programmer
+(where \*(L"average\*(R" is based on Schwern's example code).
+.PP
+Class::Accessor is slower than average, but more flexible.
+.PP
+Class::Accessor::Faster is even faster than Class::Accessor::Fast.  It uses an
+array internally, not a hash.  This could be a good or bad feature depending on
+your point of view.
+.PP
+Direct hash access is, of course, much faster than all of these, but it
+provides no encapsulation.
+.PP
+Of course, it's not as simple as saying \*(L"Class::Accessor is slower than
+average\*(R".  These are benchmarks for a simple accessor.  If your accessors do
+any sort of complicated work (such as talking to a database or writing to a
+file) the time spent doing that work will quickly swamp the time spend just
+calling the accessor.  In that case, Class::Accessor and the ones you write
+will be roughly the same speed.
+.SH "EXAMPLES"
+.IX Header "EXAMPLES"
+Here's an example of generating an accessor for every public field of
+your class.
+.PP
+.Vb 1
+\&    package Altoids;
+.Ve
+.PP
+.Vb 3
+\&    use base qw(Class::Accessor Class::Fields);
+\&    use fields qw(curiously strong mints);
+\&    Altoids\->mk_accessors( Altoids\->show_fields('Public') );
+.Ve
+.PP
+.Vb 5
+\&    sub new {
+\&        my $proto = shift;
+\&        my $class = ref $proto || $proto;
+\&        return fields::new($class);
+\&    }
+.Ve
+.PP
+.Vb 1
+\&    my Altoids $tin = Altoids\->new;
+.Ve
+.PP
+.Vb 2
+\&    $tin\->curiously('Curiouser and curiouser');
+\&    print $tin\->{curiously};    # prints 'Curiouser and curiouser'
+.Ve
+.PP
+.Vb 3
+\&    # Subclassing works, too.
+\&    package Mint::Snuff;
+\&    use base qw(Altoids);
+.Ve
+.PP
+.Vb 3
+\&    my Mint::Snuff $pouch = Mint::Snuff\->new;
+\&    $pouch\->strong('Blow your head off!');
+\&    print $pouch\->{strong};     # prints 'Blow your head off!'
+.Ve
+.PP
+Here's a simple example of altering the behavior of your accessors.
+.PP
+.Vb 3
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->mk_accessors(qw(this that up down));
+.Ve
+.PP
+.Vb 2
+\&    sub get {
+\&        my $self = shift;
+.Ve
+.PP
+.Vb 2
+\&        # Note every time someone gets some data.
+\&        print STDERR "Getting @_\en";
+.Ve
+.PP
+.Vb 2
+\&        $self\->SUPER::get(@_);
+\&    }
+.Ve
+.PP
+.Vb 2
+\&    sub set {
+\&        my ($self, $key) = splice(@_, 0, 2);
+.Ve
+.PP
+.Vb 2
+\&        # Note every time someone sets some data.
+\&        print STDERR "Setting $key to @_\en";
+.Ve
+.PP
+.Vb 2
+\&        $self\->SUPER::set($key, @_);
+\&    }
+.Ve
+.SH "CAVEATS AND TRICKS"
+.IX Header "CAVEATS AND TRICKS"
+Class::Accessor has to do some internal wackiness to get its
+job done quickly and efficiently.  Because of this, there's a few
+tricks and traps one must know about.
+.PP
+Hey, nothing's perfect.
+.Sh "Don't make a field called \s-1DESTROY\s0"
+.IX Subsection "Don't make a field called DESTROY"
+This is bad.  Since \s-1DESTROY\s0 is a magical method it would be bad for us
+to define an accessor using that name.  Class::Accessor will
+carp if you try to use it with a field named \*(L"\s-1DESTROY\s0\*(R".
+.Sh "Overriding autogenerated accessors"
+.IX Subsection "Overriding autogenerated accessors"
+You may want to override the autogenerated accessor with your own, yet
+have your custom accessor call the default one.  For instance, maybe
+you want to have an accessor which checks its input.  Normally, one
+would expect this to work:
+.PP
+.Vb 3
+\&    package Foo;
+\&    use base qw(Class::Accessor);
+\&    Foo\->mk_accessors(qw(email this that whatever));
+.Ve
+.PP
+.Vb 4
+\&    # Only accept addresses which look valid.
+\&    sub email {
+\&        my($self) = shift;
+\&        my($email) = @_;
+.Ve
+.PP
+.Vb 7
+\&        if( @_ ) {  # Setting
+\&            require Email::Valid;
+\&            unless( Email::Valid\->address($email) ) {
+\&                carp("$email doesn't look like a valid address.");
+\&                return;
+\&            }
+\&        }
+.Ve
+.PP
+.Vb 2
+\&        return $self\->SUPER::email(@_);
+\&    }
+.Ve
+.PP
+There's a subtle problem in the last example, and it's in this line:
+.PP
+.Vb 1
+\&    return $self\->SUPER::email(@_);
+.Ve
+.PP
+If we look at how Foo was defined, it called \fImk_accessors()\fR which
+stuck \fIemail()\fR right into Foo's namespace.  There *is* no
+\&\fISUPER::email()\fR to delegate to!  Two ways around this... first is to
+make a \*(L"pure\*(R" base class for Foo.  This pure class will generate the
+accessors and provide the necessary super class for Foo to use:
+.PP
+.Vb 3
+\&    package Pure::Organic::Foo;
+\&    use base qw(Class::Accessor);
+\&    Pure::Organic::Foo\->mk_accessors(qw(email this that whatever));
+.Ve
+.PP
+.Vb 2
+\&    package Foo;
+\&    use base qw(Pure::Organic::Foo);
+.Ve
+.PP
+And now \fIFoo::email()\fR can override the generated
+\&\fIPure::Organic::Foo::email()\fR and use it as \fISUPER::email()\fR.
+.PP
+This is probably the most obvious solution to everyone but me.
+Instead, what first made sense to me was for \fImk_accessors()\fR to define
+an alias of \fIemail()\fR, \fI_email_accessor()\fR.  Using this solution,
+\&\fIFoo::email()\fR would be written with:
+.PP
+.Vb 1
+\&    return $self\->_email_accessor(@_);
+.Ve
+.PP
+instead of the expected \fISUPER::email()\fR.
+.SH "AUTHORS"
+.IX Header "AUTHORS"
+Copyright 2009 Marty Pauley <marty+perl@kasei.com>
+.PP
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.  That means either (a) the \s-1GNU\s0 General Public
+License or (b) the Artistic License.
+.Sh "\s-1ORIGINAL\s0 \s-1AUTHOR\s0"
+.IX Subsection "ORIGINAL AUTHOR"
+Michael G Schwern <schwern@pobox.com>
+.Sh "\s-1THANKS\s0"
+.IX Subsection "THANKS"
+Liz and \s-1RUZ\s0 for performance tweaks.
+.PP
+Tels, for his big feature request/bug report.
+.PP
+Various presenters at YAPC::Asia 2009 for criticising the non-Moose interface.
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+See Class::Accessor::Fast and Class::Accessor::Faster if speed is more
+important than flexibility.
+.PP
+These are some modules which do similar things in different ways
+Class::Struct, Class::Methodmaker, Class::Generate,
+Class::Class, Class::Contract, Moose, Mouse
+.PP
+See Class::DBI for an example of this module in use.