fields::aliased

fields::aliased is a Perl module that can create aliases for object fields.
Download

fields::aliased Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Kevin Michael Vail
  • Publisher web site:
  • http://search.cpan.org/~kvail/Tie-StrictHash-1.0/StrictHash.pm

fields::aliased Tags


fields::aliased Description

fields::aliased is a Perl module that can create aliases for object fields. fields::aliased is a Perl module that can create aliases for object fields.SYNOPSIS package MyPackage; use strict; use fields qw($scalar @array %hash); sub new { my $class = shift; my $self = fields::new($class); return $self; } sub mymethod { my MyPackage $self = shift; use fields::aliased qw($self $scalar @array %hash); $scalar = 1; @array = (2 .. 4); %hash = ('one' => 1, 'two' => 2); }This module is a companion to the fields module, which allows efficient handling of instance variables with checking at compile time. It goes one step further and actually creates lexical aliases to the instance values, which can make code not only easier to type, but easier to read as well.DeclarationsYou declare the fields using the fields pragma, as always. use fields qw($scalar @array %hash nosigil);Each field name may be preceded by a type sigil to indicate which kind of variable it is. Names without the type sigil are treated as scalars.For names beginning with an underscore, see "PRIVATE FIELDS" below.ConstructorsYou call fields::new to create the object. my $self = fields::new($class);UsageIn each method that uses the individual fields, you add a line similar to the following: use fields::aliased qw($self $scalar @array %hash nosigil);That is, list the variable being used for the object reference, and then the names of the fields that you are going to use in this method. fields::aliased takes care of declaring the appropriate Perl lexical variables and linking them to the appropriate field. You only need to specify the fields you are actually going to use, including any inherited from superclasses.Requirements:· Perl· Tie::IxHash· Filter::Util::Call· Test::MoreWhat's New in This Release:· Initialize field values at use fields::aliased time rather than when the object is created. Net effect should be identical, but this allows private fields to work.


fields::aliased Related Software