ImplicitThis

ImplicitThis is a syntactical sugar for OO methods.
Download

ImplicitThis Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Scott Walters
  • Publisher web site:
  • http://search.cpan.org/~swalters/Math-Preference-SVD-0.01/lib/Math/Preference/SVD.pm

ImplicitThis Tags


ImplicitThis Description

ImplicitThis is a syntactical sugar for OO methods. ImplicitThis is a syntactical sugar for OO methods.SYNOPSIS use ImplicitThis; ImplicitThis::imply(); sub new { my $type = shift; my %args = @_; # must be blessed hash object bless { foo => $args{'foo'}, bar => $args{'bar'}, }, $type; } sub my_accessor { # $this is read for us. $bar is aliased to $this->{'bar'}, similiar for $foo $this->another_accessor($bar); $foo++; } sub _another_accessor { # this will die if called from something not derived from our package $foo++; }ABSTRACTMethods in OO Perl receive "$this" without having to read it. Instance field variables are accessable by name instead of having to dereference the hash ref. Privicy is enforced for methods starting with an understore.This emulates other OO languages, such as Java and C++, where the compiler implicitly and invisibly passes "this" as the first argument of each method call. While Perl passes this argument invisibly, you must manually write code to read it. Java and C++ also discover, at compile time, rather a variable is an instance variable or a static variable, without you needing to distinguish them using special syntax. We remove the extra syntax, but this is learned at run time, not compile time. Unlike Alias.pm, this code is likely to have a noticable impact on performance of code that uses OO accessors heavily.ImplicitThis::imply() places a thin wrapper is placed around methods in your object. *this{SCALAR} is a reference to a lexical we've shifted off the argument list. Aliases are created for each key in %$this to itself value in the same way.While this module works fine for me, your milage may very: it has not been extensively tested.Similar to Alias.pm. However, we're pure Perl, and _no_ additional syntax is introduced. Requirements:· Perl Requirements: · Perl


ImplicitThis Related Software