Object::LocalVars

Object::LocalVars is a Perl module with outside-in objects with local aliasing of $self and object variables.
Download

Object::LocalVars Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David A Golden
  • Publisher web site:
  • http://search.cpan.org/~dagolden/Statistics-RankOrder-0.12/lib/Statistics/RankOrder.pm

Object::LocalVars Tags


Object::LocalVars Description

Object::LocalVars is a Perl module with outside-in objects with local aliasing of $self and object variables. Object::LocalVars is a Perl module with outside-in objects with local aliasing of $self and object variables.SYNOPSIS package My::Object; use strict; use Object::LocalVars; give_methods our $self; # this exact line is required our $field1 : Prop; our $field2 : Prop; sub as_string : Method { return "$self has properties '$field1' and '$field2'"; }This is a development release. The API may change slightly. Do not use for production purposes. Comments appreciated.This module helps developers create "outside-in" objects. Properties (and $self) are declared as package globals. Method calls are wrapped such that these globals take on a local value that is correct for the specific calling object and the duration of the method call. I.e. $self is locally aliased to the calling object and properties are locally aliased to the values of the properties for that object. The package globals themselves only declare properties in the package and hold no data themselves. Data are stored in a separate namespace for each property, keyed off the reference memory addresses of the objects.Outside-in objects are similar to "inside-out" objects, which store data in a single lexical hash (or closure) for each property, which is keyed off the reference memory addresses of the objects. Both differ from classic Perl objects, which hold data for the object directly using a blessed reference or closure to a data structure, typically a hash. For both outside-in and inside-out objects, data are stored centrally and the blessed reference is simply a key to look up the right data in the central data store.The use of package variables for outside-in objects allows for the use of dynamic symbol table manipulation and aliasing. As a result, Object::LocalVars delivers a variety of features -- though with some corresponding drawbacks. Here are some key features of "Object::LocalVars": · Provides $self automatically to methods without 'my $self = shift' and the like · Provides dynamic aliasing of properties within methods -- methods can access properties directly as variables without the overhead of calls to accessors or mutators, eliminating the overhead of these calls in methods · Array and hash properties may be accessed via direct dereference of simple variables, allowing developers to push, pop, splice, etc. without the usual tortured syntax to dereference an accessor call · Properties no longer require accessors to have compile time syntax checking under strictures (i.e. 'use strict'); 'public' properties have accessors automatically provided as needed · Uses attributes to mark properties and methods, but only in the BEGIN phase so should be mod_perl friendly (though this has not been tested yet) · Provides attributes for public, protected and private properties, class properties, and methods · Orthogonality -- can subclass just about any other class, regardless of implementation. · Multiple inheritance supported in initializers and destructors (though only one superclass can be of a special, orthogonal type) · Minimally thread-safe under Perl 5.8 or greater -- objects are safely cloned across thread boundaries (or a pseudo-fork on Win32) · Achieves these features without source filtering Requirements: · Perl


Object::LocalVars Related Software