Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    OO::Closures 1.2

    Download button

    No screenshots available
    Downloads: 383  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.5/5)
    14 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Abigail | More programs
    Perl Artistic License / FREE
    May 9th, 2008, 11:02 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Object Oriented programming | Object Oriented Closures | Perl module | Object | Oriented | programming

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM