Query: accessors::classic
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
accessors::classic(3pm) User Contributed Perl Documentation accessors::classic(3pm)NAMEaccessors::classic - create 'classic' read/write accessor methods in caller's package.SYNOPSISpackage Foo; use accessors::classic qw( foo bar baz ); my $obj = bless {}, 'Foo'; # always return the current value, even on set: $obj->foo( 'hello ' ) if $obj->bar( 'world' ) eq 'world'; print $obj->foo, $obj->bar, $obj->baz( "! " );DESCRIPTIONThe accessors::classic pragma lets you create simple classic Perl accessors at compile-time. The generated methods look like this: sub foo { my $self = shift; $self->{foo} = shift if (@_); return $self->{foo}; } They always return the current value. Note that there is no dash ("-") prepended to the property name as there are in accessors. This is for backwards compatibility.PERFORMANCEThere is little-to-no performace hit when using generated accessors; in fact there is usually a performance gain. o typically 5-15% faster than hard-coded accessors (like the above example). o typically 1-15% slower than optimized accessors (less readable). o typically a small performance hit at startup (accessors are created at compile-time). o uses the same anonymous sub to reduce memory consumption (sometimes by 80%). See the benchmark tests included with this distribution for more details.CAVEATSClasses using blessed scalarrefs, arrayrefs, etc. are not supported for sake of simplicity. Only hashrefs are supported.AUTHORSteve Purkis <spurkis@cpan.org>SEE ALSOaccessors, accessors::rw, accessors::ro, accessors::chained, base perl v5.12.4 2011-10-16 accessors::classic(3pm)
Related Man Pages |
---|
class::accessor::fast(3pm) - linux |
object::accessor(3pm) - mojave |
object::accessor5.18(3pm) - mojave |
class::xsaccessor(3pm) - debian |
accessors::ro(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
perl function call tracking |
Sun wrestles itself with StarOffice 9 |
Here's To The Crazy One |
Read / write file exemples |
A journey down memory lane - AMIGA... |