OO::Closures

OO::Closures is an Object Oriented programming using Closures.
Download

OO::Closures Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Abigail
  • Publisher web site:
  • http://search.cpan.org/~abigail/

OO::Closures Tags


OO::Closures Description

OO::Closures is an Object Oriented programming using Closures. OO::Closures is an Object Oriented programming using Closures.SYNOPSIS use OO::Closures; sub new { my (%methods, %ISA, $self); $self = create_object (%methods, %ISA, !@_); ... $self; }This package gives you a way to use Object Oriented programming using Closures, including multiple inheritance, SUPER:: and AUTOLOADing.To create the object, call the function create_object with three arguments, a reference to a hash containing the methods of the object, a reference to a hash containing the inherited objects, and a flag determining whether the just created object is the base object or not. This latter flag is important when it comes to trying AUTOLOAD after not finding a method.create_object returns a closure which will act as the new object.Here is an example of the usage: use OO::Closures; sub dice { my (%methods, %ISA, $self); $self = create_object (%methods, %ISA, !@_); my $faces = 6; $methods {set} = sub {$faces = shift;}; $methods {roll} = sub {1 + int rand $faces}; $self; }It is a simple object representing a die, with 2 methods, set, to set the number of faces, and roll, to roll the die. It does not inherit anything. To make a roll on a 10 sided die, use: (my $die = dice) -> (set => 10); print $die -> ('roll');Note that since the objects are closures, method names are the first arguments of the calls.Requirements:· Perl Requirements: · Perl


OO::Closures Related Software