mixin
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 17
Class::Prototyped::Mixin 2.4
Class::Prototyped::Mixin Perl module contains Mixin Support for Class::Prototyped. more>>
Class::Prototyped::Mixin Perl module contains Mixin Support for Class::Prototyped.
SYNOPSIS
Usage one: whip up a class and toss it in a scalar
package HelloWorld;
sub hello {
my ($self, $age) = @_;
return "Hello World! I am $age years old"
}
package HelloWorld::Uppercase;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
uc $ret
}
);
package HelloWorld::Bold;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< b >$ret< /b >";
}
);
package HelloWorld::Italic;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< i >$ret< /i >";
}
);
# script.pl - now the whipping begins
use Class::Prototyped::Mixin qw(mixin);
my $runtime = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Italic
);
print $runtime->hello(74);
< i >HELLO WORLD! I AM 74 YEARS OLD< /i >
Usage two: create hierarchy and install in a Class::Prototyped package
package CompileTime;
use Class::Prototyped::Mixin qw(mixin);
my $uclass = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Bold
);
__PACKAGE__->reflect->addSlot(
* => $uclass
);
# script.pl
use CompileTime;
print CompileTime->hello(88);
< b >HELLO WORLD! I AM 88 YEARS OLD< /b >
<<lessSYNOPSIS
Usage one: whip up a class and toss it in a scalar
package HelloWorld;
sub hello {
my ($self, $age) = @_;
return "Hello World! I am $age years old"
}
package HelloWorld::Uppercase;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
uc $ret
}
);
package HelloWorld::Bold;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< b >$ret< /b >";
}
);
package HelloWorld::Italic;
use base qw(Class::Prototyped);
__PACKAGE__->reflect->addSlot(
[qw(hello superable)] => sub {
my $self = shift;
my $ret = $self->reflect->super(hello, @_);
"< i >$ret< /i >";
}
);
# script.pl - now the whipping begins
use Class::Prototyped::Mixin qw(mixin);
my $runtime = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Italic
);
print $runtime->hello(74);
< i >HELLO WORLD! I AM 74 YEARS OLD< /i >
Usage two: create hierarchy and install in a Class::Prototyped package
package CompileTime;
use Class::Prototyped::Mixin qw(mixin);
my $uclass = mixin(
HelloWorld => HelloWorld::Uppercase, HelloWorld::Bold
);
__PACKAGE__->reflect->addSlot(
* => $uclass
);
# script.pl
use CompileTime;
print CompileTime->hello(88);
< b >HELLO WORLD! I AM 88 YEARS OLD< /b >
Download (0.011MB)
Added: 2007-07-31 License: Perl Artistic License Price:
815 downloads
moosicWebGUI 0.9
moosicWebGUI is a stand alone client program for controlling the moosic jukebox system. more>>
moosicWebGUI is a stand alone client program for controlling the moosic jukebox system. moosicWebGUI implements not only basic basic player functions but also more sophisticated functions for manipulating the playlist. It incorporates a small Web server based on Pythons SimpleHTTPServer library.
Main features:
- general player commands:
start, stop, next, previous, pause, skip +10/-10, repeat (loop), ...
- playlist commands:
shuffle, sort, reverse, delete duplicates, clear, save to file, load from file
- browse and search modes:
browse/search playlist, browse/search history, browse/search local files, tree view
- insert options:
single files or all music files in single directory or whole directory tree;
- add to top or bottom of playlist or mixin
Enhancements:
- Startup was accelerated.
- An online handbook was started.
- Links to the online handbook and to the manual page were added to the template.
- The man page was improved.
<<lessMain features:
- general player commands:
start, stop, next, previous, pause, skip +10/-10, repeat (loop), ...
- playlist commands:
shuffle, sort, reverse, delete duplicates, clear, save to file, load from file
- browse and search modes:
browse/search playlist, browse/search history, browse/search local files, tree view
- insert options:
single files or all music files in single directory or whole directory tree;
- add to top or bottom of playlist or mixin
Enhancements:
- Startup was accelerated.
- An online handbook was started.
- Links to the online handbook and to the manual page were added to the template.
- The man page was improved.
Download (0.027MB)
Added: 2005-12-04 License: GPL (GNU General Public License) Price:
1419 downloads
Text::MicroMason::Mason 1.96.0
Text::MicroMason::Mason is a simple compiler for Mason-style Templating. more>>
Text::MicroMason::Mason is a simple compiler for Mason-style Templating.
SYNOPSIS
Mason syntax provides several ways to mix Perl into a text template:
< %args >
$name
< /%args >
% if ( $name eq Dave ) {
Im sorry < % $name % >, Im afraid I cant do that right now.
% } else {
< %perl >
my $hour = (localtime)[2];
my $daypart = ( $hour > 11 ) ? afternoon : morning;
< /%perl >
Good < % $daypart % >, < % $name % >!
% }
< & "includes/standard_footer.msn" & >
< %doc >
Heres a private developr comment describing this template.
< /%doc >
Create a Mason object to interpret the templates:
use Text::MicroMason;
my $mason = Text::MicroMason->new();
You can compile and execute templates using the standard MicroMason methods:
$coderef = $mason->compile( file => simple.tmpl );
print $coderef->( %arguments );
print $mason->execute( file => simple.tmpl, %arguments );
Main features:
- Template interpolation with
- Literal Perl lines with leading %
- Named %args, %perl, %once, %init, %cleanup, and %doc blocks
- The $m mason object, although with many fewer methods
- Expression filtering with |h and |u (via -Filter mixin)
<<lessSYNOPSIS
Mason syntax provides several ways to mix Perl into a text template:
< %args >
$name
< /%args >
% if ( $name eq Dave ) {
Im sorry < % $name % >, Im afraid I cant do that right now.
% } else {
< %perl >
my $hour = (localtime)[2];
my $daypart = ( $hour > 11 ) ? afternoon : morning;
< /%perl >
Good < % $daypart % >, < % $name % >!
% }
< & "includes/standard_footer.msn" & >
< %doc >
Heres a private developr comment describing this template.
< /%doc >
Create a Mason object to interpret the templates:
use Text::MicroMason;
my $mason = Text::MicroMason->new();
You can compile and execute templates using the standard MicroMason methods:
$coderef = $mason->compile( file => simple.tmpl );
print $coderef->( %arguments );
print $mason->execute( file => simple.tmpl, %arguments );
Main features:
- Template interpolation with
- Literal Perl lines with leading %
- Named %args, %perl, %once, %init, %cleanup, and %doc blocks
- The $m mason object, although with many fewer methods
- Expression filtering with |h and |u (via -Filter mixin)
Download (0.046MB)
Added: 2007-08-09 License: Perl Artistic License Price:
806 downloads
Data::Inherited 1.00
Data::Inherited is a Perl module with hierarchy-wide accumulation of list and hash results. more>>
Data::Inherited is a Perl module with hierarchy-wide accumulation of list and hash results.
SYNOPSIS
package Foo;
use base Data::Inherited;
use constant PROPERTIES => (qw/name address/);
package Bar;
use base Foo;
use constant PROPERTIES => (qw/age/);
package main;
my $bar = Bar->new;
print "$_n" for $bar->every_list(PROPERTIES);
prints
name
address
age
This is a mixin class. By inheriting from it you get two methods that are able to accumulate hierarchy-wide list and hash results.
every_list(String $method_name, Bool ?$override_cache = 0)
Takes as arguments a method name (mandatory) and a boolean indicating whether to override the cache (optional, off by default)
Causes every method in the objects hierarchy with the given name to be invoked. The resulting list is the combined set of results from all the methods, pushed together in top-to-bottom order (hierarchy-wise).
every_list() returns a list in list context and an array reference in scalar context.
The result is cached (per calling package) and the next time the method is called from the same package with the same method argument, the cached result is returned.
This is to speed up method calls, because internally this module uses NEXT, which is quite slow. It is expected that every_list() is used for methods returning static lists (object defaults, static class definitions and such). If you want to override the caching mechanism, you can provide the optional second argument. The result is cached in any case.
<<lessSYNOPSIS
package Foo;
use base Data::Inherited;
use constant PROPERTIES => (qw/name address/);
package Bar;
use base Foo;
use constant PROPERTIES => (qw/age/);
package main;
my $bar = Bar->new;
print "$_n" for $bar->every_list(PROPERTIES);
prints
name
address
age
This is a mixin class. By inheriting from it you get two methods that are able to accumulate hierarchy-wide list and hash results.
every_list(String $method_name, Bool ?$override_cache = 0)
Takes as arguments a method name (mandatory) and a boolean indicating whether to override the cache (optional, off by default)
Causes every method in the objects hierarchy with the given name to be invoked. The resulting list is the combined set of results from all the methods, pushed together in top-to-bottom order (hierarchy-wise).
every_list() returns a list in list context and an array reference in scalar context.
The result is cached (per calling package) and the next time the method is called from the same package with the same method argument, the cached result is returned.
This is to speed up method calls, because internally this module uses NEXT, which is quite slow. It is expected that every_list() is used for methods returning static lists (object defaults, static class definitions and such). If you want to override the caching mechanism, you can provide the optional second argument. The result is cached in any case.
Download (0.012MB)
Added: 2007-01-15 License: Perl Artistic License Price:
1012 downloads
Text::MicroMason::HTMLMason 1.992
Text::MicroMason::HTMLMason is a simple compiler for Mason-style Templating. more>>
Text::MicroMason::HTMLMason is a simple compiler for Mason-style Templating.
SYNOPSIS
Create a MicroMason object to interpret the templates:
use Text::MicroMason;
my $mason = Text::MicroMason->new();
Use the standard compile and execute methods to parse and evalute templates:
print $mason->compile( text=>$template )->( @%args );
print $mason->execute( text=>$template, @args );
Mason syntax provides several ways to mix Perl into a text template:
< %args >
$name
< /%args >
% if ( $name eq Dave ) {
Im sorry < % $name % >, Im afraid I cant do that right now.
% } else {
< %perl >
my $hour = (localtime)[2];
my $daypart = ( $hour > 11 ) ? afternoon : morning;
< /%perl >
Good < % $daypart % >, < % $name % >!
% }
< & "includes/standard_footer.msn" & >
< %doc >
Heres a private developr comment describing this template.
< /%doc >
Main features:
- Template interpolation with
- Literal Perl lines with leading %
- Named %args, %perl, %once, %init, %cleanup, and %doc blocks
- The $m mason object, although with many fewer methods
- Expression filtering with |h and |u (via -Filter mixin)
<<lessSYNOPSIS
Create a MicroMason object to interpret the templates:
use Text::MicroMason;
my $mason = Text::MicroMason->new();
Use the standard compile and execute methods to parse and evalute templates:
print $mason->compile( text=>$template )->( @%args );
print $mason->execute( text=>$template, @args );
Mason syntax provides several ways to mix Perl into a text template:
< %args >
$name
< /%args >
% if ( $name eq Dave ) {
Im sorry < % $name % >, Im afraid I cant do that right now.
% } else {
< %perl >
my $hour = (localtime)[2];
my $daypart = ( $hour > 11 ) ? afternoon : morning;
< /%perl >
Good < % $daypart % >, < % $name % >!
% }
< & "includes/standard_footer.msn" & >
< %doc >
Heres a private developr comment describing this template.
< /%doc >
Main features:
- Template interpolation with
- Literal Perl lines with leading %
- Named %args, %perl, %once, %init, %cleanup, and %doc blocks
- The $m mason object, although with many fewer methods
- Expression filtering with |h and |u (via -Filter mixin)
Download (0.068MB)
Added: 2007-08-09 License: Perl Artistic License Price:
807 downloads
PLWM 2.6a
PLWM is a Python package, containing classes suitable for implementing a window manager. more>>
PLWM is a Python package, containing classes suitable for implementing a window manager. PLWM is also a window manager, using the PLWM package.
Enhancements:
- This is mostly a bug fix release, to get the latest set of fixes out the door.
- Distutils is now used to build and install plwm.
- We now require Python 2.0 or later. Python 1.5 is no longer supported.
Mike Meyer (mwm@mired.org) is now administering PLWM.
New mixin: mixer.py.
- This is a new mixin for controlling the audio mixer. Currently, it only supports "rexima", but it should be easy to extend to "aumix" etc.
Menu screen mixin is now configurable.
- The menu screen mixin has been extended to use menu_font, menu_foreground, menu_background, menu_bordercolor, and menu_borderwidth when it draws menus on the screen. The default is 9x15Bold, black, white, black and 3. menu_seconds is the number of seconds the menu will be onscreen before it vanishes of its own accord. The default value is 0, which means to stay until a selection is made or the menu is cancelled.
Message screen mixin is now configurable.
- The message screen mixin can now be configured with message_font, message_foreground, message_background, message_bordercolor and message_borderwidth. message_seconds controls how long the message is displayed for, with a default value of 5 seconds.
Screen.system now allows i/o redirection.
- The Screen.system method now takes an extra argument, redirect. This argument should either be a single integer between 0 and 2 inclusive, or a tuple of such integers. These fds are redirected to pipes, and the resulting pipes are returned as a three-tuple. Supplying redirect implies that the command will be run in the background.
<<lessEnhancements:
- This is mostly a bug fix release, to get the latest set of fixes out the door.
- Distutils is now used to build and install plwm.
- We now require Python 2.0 or later. Python 1.5 is no longer supported.
Mike Meyer (mwm@mired.org) is now administering PLWM.
New mixin: mixer.py.
- This is a new mixin for controlling the audio mixer. Currently, it only supports "rexima", but it should be easy to extend to "aumix" etc.
Menu screen mixin is now configurable.
- The menu screen mixin has been extended to use menu_font, menu_foreground, menu_background, menu_bordercolor, and menu_borderwidth when it draws menus on the screen. The default is 9x15Bold, black, white, black and 3. menu_seconds is the number of seconds the menu will be onscreen before it vanishes of its own accord. The default value is 0, which means to stay until a selection is made or the menu is cancelled.
Message screen mixin is now configurable.
- The message screen mixin can now be configured with message_font, message_foreground, message_background, message_bordercolor and message_borderwidth. message_seconds controls how long the message is displayed for, with a default value of 5 seconds.
Screen.system now allows i/o redirection.
- The Screen.system method now takes an extra argument, redirect. This argument should either be a single integer between 0 and 2 inclusive, or a tuple of such integers. These fds are redirected to pipes, and the resulting pipes are returned as a three-tuple. Supplying redirect implies that the command will be run in the background.
Download (0.44MB)
Added: 2005-08-12 License: GPL (GNU General Public License) Price:
1534 downloads
XOTcl 1.5.3
XOTcl is an Object-oriented scripting language. more>>
XOTcl (XOTcl, pronounced exotickle) is an object-oriented scripting language based on MITs OTcl. XOTcl is intended as a value added replacement for OTcl.
XOTcl is an open source project which was initiated by Gustaf Neumann and Uwe Zdun, its main developers. The following people have contributed to XOTcl: Neophytos Demetriou, Fredj Dridi, Laurent Duperval, Teemu Hukkanen, MichaelL@frogware.com, Kristoffer Lawson, David LeBlanc, Catherine Letondal, Antti Salonen, Daniel Steffen, and Zoran Vasiljevic.
Scripting languages, like Tcl, are designed for glueing components together, provide features like dynamic extensibility and dynamic typing with automatic conversion, that make them well suited for rapid application development.
The basic object system of XOTcl is adopted from OTcl. The object system enables us to define objects, classes, and meta-classes. Classes are special objects with the purpose of managing other objects. ``Managing means that a class controls the creation and destruction of its instances and that it contains a repository of methods accessible for the instances.
Every object may be enhanced with object-specific methods. XOTcl supports single and multiple inheritance. All relationships in XOTcl, including class and superclass relationships, are completely dynamic and can be introspected. Through method chaining without explicit naming of the intended method, ambiguities in name resolution of methods are avoided. This way a shadowed method can be ``mixed into the execution of the current method.
XOTcl combines the ideas of scripting and object-orientation in a way that preserves the benefits of both of them. It is equipped with several new language functionalities that help building and managing complex systems. We added the following support:
Main features:
- Dynamic Object Aggregations, to provide dynamic aggregations through nested namespaces (objects).
- Nested Classes, to reduce the interference of independently developed program structures.
- Assertions, to reduce the interface and the reliability problems caused by dynamic typing and, therefore, to ease the combination of many components.
- Meta-data, to enhance self-documentation of objects and classes.
- Per-object mixins, as a means to improve flexibility of mixin methods by giving an object access to several different supplemental classes, which may be changed dynamically.
- Per-class mixins, as a means to improve flexibility of mixin methods to a class, all instances of the class have access to the mixed in methods like for multiple inheritance, but without the need of intersection classes.
- Filters (per class and per object) as a means of abstractions over method invocations to implement large program structures, like design patterns.
- Conditional Filters and Mixins can be used to perform context aware composition depending on guards (conditions which decide whether the interceptor should be used). All kinds of filters or mixins can be used conditionally.
- Dynamic Component Loading XOTcl integrates the Tcl package loading with architectrual support for integration with object-oriented constructs. Moreover, it provides tracking/tracing of component loading.
<<lessXOTcl is an open source project which was initiated by Gustaf Neumann and Uwe Zdun, its main developers. The following people have contributed to XOTcl: Neophytos Demetriou, Fredj Dridi, Laurent Duperval, Teemu Hukkanen, MichaelL@frogware.com, Kristoffer Lawson, David LeBlanc, Catherine Letondal, Antti Salonen, Daniel Steffen, and Zoran Vasiljevic.
Scripting languages, like Tcl, are designed for glueing components together, provide features like dynamic extensibility and dynamic typing with automatic conversion, that make them well suited for rapid application development.
The basic object system of XOTcl is adopted from OTcl. The object system enables us to define objects, classes, and meta-classes. Classes are special objects with the purpose of managing other objects. ``Managing means that a class controls the creation and destruction of its instances and that it contains a repository of methods accessible for the instances.
Every object may be enhanced with object-specific methods. XOTcl supports single and multiple inheritance. All relationships in XOTcl, including class and superclass relationships, are completely dynamic and can be introspected. Through method chaining without explicit naming of the intended method, ambiguities in name resolution of methods are avoided. This way a shadowed method can be ``mixed into the execution of the current method.
XOTcl combines the ideas of scripting and object-orientation in a way that preserves the benefits of both of them. It is equipped with several new language functionalities that help building and managing complex systems. We added the following support:
Main features:
- Dynamic Object Aggregations, to provide dynamic aggregations through nested namespaces (objects).
- Nested Classes, to reduce the interference of independently developed program structures.
- Assertions, to reduce the interface and the reliability problems caused by dynamic typing and, therefore, to ease the combination of many components.
- Meta-data, to enhance self-documentation of objects and classes.
- Per-object mixins, as a means to improve flexibility of mixin methods by giving an object access to several different supplemental classes, which may be changed dynamically.
- Per-class mixins, as a means to improve flexibility of mixin methods to a class, all instances of the class have access to the mixed in methods like for multiple inheritance, but without the need of intersection classes.
- Filters (per class and per object) as a means of abstractions over method invocations to implement large program structures, like design patterns.
- Conditional Filters and Mixins can be used to perform context aware composition depending on guards (conditions which decide whether the interceptor should be used). All kinds of filters or mixins can be used conditionally.
- Dynamic Component Loading XOTcl integrates the Tcl package loading with architectrual support for integration with object-oriented constructs. Moreover, it provides tracking/tracing of component loading.
Download (1.8MB)
Added: 2006-11-26 License: GPL (GNU General Public License) Price:
1062 downloads
Spiffy 0.30
Spiffy is a Spiffy Perl Interface Framework For You. more>>
Spiffy is a Spiffy Perl Interface Framework For You.
SYNOPSIS
package Keen;
use Spiffy -Base;
field mirth;
const mood => :-);
sub happy {
if ($self->mood eq :-() {
$self->mirth(-1);
print "Cheer up!";
}
super;
}
"Spiffy" is a framework and methodology for doing object oriented (OO) programming in Perl. Spiffy combines the best parts of Exporter.pm, base.pm, mixin.pm and SUPER.pm into one magic foundation class. It attempts to fix all the nits and warts of traditional Perl OO, in a clean, straightforward and (perhaps someday) standard way.
Spiffy borrows ideas from other OO languages like Python, Ruby, Java and Perl 6. It also adds a few tricks of its own.
If you take a look on CPAN, there are a ton of OO related modules. When starting a new project, you need to pick the set of modules that makes most sense, and then you need to use those modules in each of your classes. Spiffy, on the other hand, has everything youll probably need in one module, and you only need to use it once in one of your classes. If you make Spiffy.pm the base class of the basest class in your project, Spiffy will automatically pass all of its magic to all of your subclasses. You may eventually forget that youre even using it!
The most striking difference between Spiffy and other Perl object oriented base classes, is that it has the ability to export things. If you create a subclass of Spiffy, all the things that Spiffy exports will automatically be exported by your subclass, in addition to any more things that you want to export. And if someone creates a subclass of your subclass, all of those things will be exported automatically, and so on. Think of it as "Inherited Exportation", and it uses the familiar Exporter.pm specification syntax.
To use Spiffy or any subclass of Spiffy as a base class of your class, you specify the -base argument to the use command.
use MySpiffyBaseModule -base;
You can also use the traditional use base MySpiffyBaseModule; syntax and everything will work exactly the same. The only caveat is that Spiffy.pm must already be loaded. Thats because Spiffy rewires base.pm on the fly to do all the Spiffy magics.
Spiffy has support for Ruby-like mixins with Perl6-like roles. Just like base you can use either of the following invocations:
use mixin MySpiffyBaseModule;
use MySpiffyBaseModule -mixin;
The second version will only work if the class being mixed in is a subclass of Spiffy. The first version will work in all cases, as long as Spiffy has already been loaded.
To limit the methods that get mixed in, use roles. (Hint: they work just like an Exporter list):
use MySpiffyBaseModule -mixin => qw(:basics x y !foo);
In object oriented Perl almost every subroutine is a method. Each method gets the object passed to it as its first argument. That means practically every subroutine starts with the line:
my $self = shift;
Spiffy provides a simple, optional filter mechanism to insert that line for you, resulting in cleaner code. If you figure an average method has 10 lines of code, thats 10% of your code! To turn this option on, you just use the -Base option instead of the -base option, or add the -selfless option. If source filtering makes you queazy, dont use the feature. I personally find it addictive in my quest for writing squeaky clean, maintainable code.
A useful feature of Spiffy is that it exports two functions: field and const that can be used to declare the attributes of your class, and automatically generate accessor methods for them. The only difference between the two functions is that const attributes can not be modified; thus the accessor is much faster.
One interesting aspect of OO programming is when a method calls the same method from a parent class. This is generally known as calling a super method. Perls facility for doing this is butt ugly:
sub cleanup {
my $self = shift;
$self->scrub;
$self->SUPER::cleanup(@_);
}
Spiffy makes it, er, super easy to call super methods. You just use the super function. You dont need to pass it any arguments because it automatically passes them on for you. Heres the same function with Spiffy:
sub cleanup {
$self->scrub;
super;
}
Spiffy has a special method for parsing arguments called parse_arguments, that it also uses for parsing its own arguments. You declare which arguments are boolean (singletons) and which ones are paired, with two special methods called boolean_arguments and paired_arguments. Parse arguments pulls out the booleans and pairs and returns them in an anonymous hash, followed by a list of the unmatched arguments.
Finally, Spiffy can export a few debugging functions WWW, XXX, YYY and ZZZ. Each of them produces a YAML dump of its arguments. WWW warns the output, XXX dies with the output, YYY prints the output, and ZZZ confesses the output. If YAML doesnt suit your needs, you can switch all the dumps to Data::Dumper format with the -dumper option.
<<lessSYNOPSIS
package Keen;
use Spiffy -Base;
field mirth;
const mood => :-);
sub happy {
if ($self->mood eq :-() {
$self->mirth(-1);
print "Cheer up!";
}
super;
}
"Spiffy" is a framework and methodology for doing object oriented (OO) programming in Perl. Spiffy combines the best parts of Exporter.pm, base.pm, mixin.pm and SUPER.pm into one magic foundation class. It attempts to fix all the nits and warts of traditional Perl OO, in a clean, straightforward and (perhaps someday) standard way.
Spiffy borrows ideas from other OO languages like Python, Ruby, Java and Perl 6. It also adds a few tricks of its own.
If you take a look on CPAN, there are a ton of OO related modules. When starting a new project, you need to pick the set of modules that makes most sense, and then you need to use those modules in each of your classes. Spiffy, on the other hand, has everything youll probably need in one module, and you only need to use it once in one of your classes. If you make Spiffy.pm the base class of the basest class in your project, Spiffy will automatically pass all of its magic to all of your subclasses. You may eventually forget that youre even using it!
The most striking difference between Spiffy and other Perl object oriented base classes, is that it has the ability to export things. If you create a subclass of Spiffy, all the things that Spiffy exports will automatically be exported by your subclass, in addition to any more things that you want to export. And if someone creates a subclass of your subclass, all of those things will be exported automatically, and so on. Think of it as "Inherited Exportation", and it uses the familiar Exporter.pm specification syntax.
To use Spiffy or any subclass of Spiffy as a base class of your class, you specify the -base argument to the use command.
use MySpiffyBaseModule -base;
You can also use the traditional use base MySpiffyBaseModule; syntax and everything will work exactly the same. The only caveat is that Spiffy.pm must already be loaded. Thats because Spiffy rewires base.pm on the fly to do all the Spiffy magics.
Spiffy has support for Ruby-like mixins with Perl6-like roles. Just like base you can use either of the following invocations:
use mixin MySpiffyBaseModule;
use MySpiffyBaseModule -mixin;
The second version will only work if the class being mixed in is a subclass of Spiffy. The first version will work in all cases, as long as Spiffy has already been loaded.
To limit the methods that get mixed in, use roles. (Hint: they work just like an Exporter list):
use MySpiffyBaseModule -mixin => qw(:basics x y !foo);
In object oriented Perl almost every subroutine is a method. Each method gets the object passed to it as its first argument. That means practically every subroutine starts with the line:
my $self = shift;
Spiffy provides a simple, optional filter mechanism to insert that line for you, resulting in cleaner code. If you figure an average method has 10 lines of code, thats 10% of your code! To turn this option on, you just use the -Base option instead of the -base option, or add the -selfless option. If source filtering makes you queazy, dont use the feature. I personally find it addictive in my quest for writing squeaky clean, maintainable code.
A useful feature of Spiffy is that it exports two functions: field and const that can be used to declare the attributes of your class, and automatically generate accessor methods for them. The only difference between the two functions is that const attributes can not be modified; thus the accessor is much faster.
One interesting aspect of OO programming is when a method calls the same method from a parent class. This is generally known as calling a super method. Perls facility for doing this is butt ugly:
sub cleanup {
my $self = shift;
$self->scrub;
$self->SUPER::cleanup(@_);
}
Spiffy makes it, er, super easy to call super methods. You just use the super function. You dont need to pass it any arguments because it automatically passes them on for you. Heres the same function with Spiffy:
sub cleanup {
$self->scrub;
super;
}
Spiffy has a special method for parsing arguments called parse_arguments, that it also uses for parsing its own arguments. You declare which arguments are boolean (singletons) and which ones are paired, with two special methods called boolean_arguments and paired_arguments. Parse arguments pulls out the booleans and pairs and returns them in an anonymous hash, followed by a list of the unmatched arguments.
Finally, Spiffy can export a few debugging functions WWW, XXX, YYY and ZZZ. Each of them produces a YAML dump of its arguments. WWW warns the output, XXX dies with the output, YYY prints the output, and ZZZ confesses the output. If YAML doesnt suit your needs, you can switch all the dumps to Data::Dumper format with the -dumper option.
Download (0.027MB)
Added: 2007-06-13 License: Perl Artistic License Price:
863 downloads
Class::Accessor::Fast::Contained 0.05
Class::Accessor::Fast::Contained is a Perl module for fast accessors with data containment. more>>
Class::Accessor::Fast::Contained is a Perl module for fast accessors with data containment.
SYNOPSIS
package Foo;
use base qw(Class::Accessor::Fast::Contained);
# The rest is the same as Class::Accessor::Fast
This module does two things differently to the venerable Class::Accessor::Fast :
Fields are stored at arms-length within a single hash value of $self, rather than directly in the $self blessed referent.
new() allows mixin into an existing object, rather than creating and returning a new blessed hashref. To do this, just call something like:
my $self = Some::Other::Class->new;
$self = $self->Class::Accessor::Fast::Contained::new;
Note that the mixin code only supports objects which use a blessed hash reference or a blessed typeglob reference.
An alias setup() is available which does the same as new() but might make more sense if being used in this way.
<<lessSYNOPSIS
package Foo;
use base qw(Class::Accessor::Fast::Contained);
# The rest is the same as Class::Accessor::Fast
This module does two things differently to the venerable Class::Accessor::Fast :
Fields are stored at arms-length within a single hash value of $self, rather than directly in the $self blessed referent.
new() allows mixin into an existing object, rather than creating and returning a new blessed hashref. To do this, just call something like:
my $self = Some::Other::Class->new;
$self = $self->Class::Accessor::Fast::Contained::new;
Note that the mixin code only supports objects which use a blessed hash reference or a blessed typeglob reference.
An alias setup() is available which does the same as new() but might make more sense if being used in this way.
Download (0.005MB)
Added: 2007-03-15 License: GPL (GNU General Public License) Price:
953 downloads
Class::Spiffy 0.15
Class::Spiffy is a Spiffy Framework with No Source Filtering. more>>
Class::Spiffy is a Spiffy Framework with No Source Filtering.
SYNOPSIS
package Keen;
use strict;
use warnings;
use Class::Spiffy -base;
field mirth;
const mood => :-);
sub happy {
my $self = shift;
if ($self->mood eq :-() {
$self->mirth(-1);
print "Cheer up!";
}
super;
}
1;
"Class::Spiffy" is a framework and methodology for doing object oriented (OO) programming in Perl. Class::Spiffy combines the best parts of Exporter.pm, base.pm, mixin.pm and SUPER.pm into one magic foundation class. It attempts to fix all the nits and warts of traditional Perl OO, in a clean, straightforward and (perhaps someday) standard way.
Class::Spiffy borrows ideas from other OO languages like Python, Ruby, Java and Perl 6. It also adds a few tricks of its own.
If you take a look on CPAN, there are a ton of OO related modules. When starting a new project, you need to pick the set of modules that makes most sense, and then you need to use those modules in each of your classes. Class::Spiffy, on the other hand, has everything youll probably need in one module, and you only need to use it once in one of your classes. If you make Class::Spiffy the base class of the basest class in your project, Class::Spiffy will automatically pass all of its magic to all of your subclasses. You may eventually forget that youre even using it!
The most striking difference between Class::Spiffy and other Perl object oriented base classes, is that it has the ability to export things. If you create a subclass of Class::Spiffy, all the things that Class::Spiffy exports will automatically be exported by your subclass, in addition to any more things that you want to export. And if someone creates a subclass of your subclass, all of those things will be exported automatically, and so on. Think of it as "Inherited Exportation", and it uses the familiar Exporter.pm specification syntax.
To use Class::Spiffy or any subclass of Class::Spiffy as a base class of your class, you specify the -base argument to the use command.
use MySpiffyBaseModule -base;
You can also use the traditional use base MySpiffyBaseModule; syntax and everything will work exactly the same. The only caveat is that Class::Spiffy must already be loaded. Thats because Class::Spiffy rewires base.pm on the fly to do all the Spiffy magics.
Class::Spiffy has support for Ruby-like mixins with Perl6-like roles. Just like base you can use either of the following invocations:
use mixin MySpiffyBaseModule;
use MySpiffyBaseModule -mixin;
The second version will only work if the class being mixed in is a subclass of Class::Spiffy. The first version will work in all cases, as long as Class::Spiffy has already been loaded.
To limit the methods that get mixed in, use roles. (Hint: they work just like an Exporter list):
use MySpiffyBaseModule -mixin => qw(:basics x y !foo);
A useful feature of Class::Spiffy is that it exports two functions: field and const that can be used to declare the attributes of your class, and automatically generate accessor methods for them. The only difference between the two functions is that const attributes can not be modified; thus the accessor is much faster.
One interesting aspect of OO programming is when a method calls the same method from a parent class. This is generally known as calling a super method. Perls facility for doing this is butt ugly:
sub cleanup {
my $self = shift;
$self->scrub;
$self->SUPER::cleanup(@_);
}
Class::Spiffy makes it, er, super easy to call super methods. You just use the super function. You dont need to pass it any arguments because it automatically passes them on for you. Heres the same function with Class::Spiffy:
sub cleanup {
my $self = shift;
$self->scrub;
super;
}
Class::Spiffy has a special method for parsing arguments called parse_arguments, that it also uses for parsing its own arguments. You declare which arguments are boolean (singletons) and which ones are paired, with two special methods called boolean_arguments and paired_arguments. Parse arguments pulls out the booleans and pairs and returns them in an anonymous hash, followed by a list of the unmatched arguments.
Finally, Class::Spiffy can export a few debugging functions WWW, XXX, YYY and ZZZ. Each of them produces a YAML dump of its arguments. WWW warns the output, XXX dies with the output, YYY prints the output, and ZZZ confesses the output. If YAML doesnt suit your needs, you can switch all the dumps to Data::Dumper format with the - dumper option.
<<lessSYNOPSIS
package Keen;
use strict;
use warnings;
use Class::Spiffy -base;
field mirth;
const mood => :-);
sub happy {
my $self = shift;
if ($self->mood eq :-() {
$self->mirth(-1);
print "Cheer up!";
}
super;
}
1;
"Class::Spiffy" is a framework and methodology for doing object oriented (OO) programming in Perl. Class::Spiffy combines the best parts of Exporter.pm, base.pm, mixin.pm and SUPER.pm into one magic foundation class. It attempts to fix all the nits and warts of traditional Perl OO, in a clean, straightforward and (perhaps someday) standard way.
Class::Spiffy borrows ideas from other OO languages like Python, Ruby, Java and Perl 6. It also adds a few tricks of its own.
If you take a look on CPAN, there are a ton of OO related modules. When starting a new project, you need to pick the set of modules that makes most sense, and then you need to use those modules in each of your classes. Class::Spiffy, on the other hand, has everything youll probably need in one module, and you only need to use it once in one of your classes. If you make Class::Spiffy the base class of the basest class in your project, Class::Spiffy will automatically pass all of its magic to all of your subclasses. You may eventually forget that youre even using it!
The most striking difference between Class::Spiffy and other Perl object oriented base classes, is that it has the ability to export things. If you create a subclass of Class::Spiffy, all the things that Class::Spiffy exports will automatically be exported by your subclass, in addition to any more things that you want to export. And if someone creates a subclass of your subclass, all of those things will be exported automatically, and so on. Think of it as "Inherited Exportation", and it uses the familiar Exporter.pm specification syntax.
To use Class::Spiffy or any subclass of Class::Spiffy as a base class of your class, you specify the -base argument to the use command.
use MySpiffyBaseModule -base;
You can also use the traditional use base MySpiffyBaseModule; syntax and everything will work exactly the same. The only caveat is that Class::Spiffy must already be loaded. Thats because Class::Spiffy rewires base.pm on the fly to do all the Spiffy magics.
Class::Spiffy has support for Ruby-like mixins with Perl6-like roles. Just like base you can use either of the following invocations:
use mixin MySpiffyBaseModule;
use MySpiffyBaseModule -mixin;
The second version will only work if the class being mixed in is a subclass of Class::Spiffy. The first version will work in all cases, as long as Class::Spiffy has already been loaded.
To limit the methods that get mixed in, use roles. (Hint: they work just like an Exporter list):
use MySpiffyBaseModule -mixin => qw(:basics x y !foo);
A useful feature of Class::Spiffy is that it exports two functions: field and const that can be used to declare the attributes of your class, and automatically generate accessor methods for them. The only difference between the two functions is that const attributes can not be modified; thus the accessor is much faster.
One interesting aspect of OO programming is when a method calls the same method from a parent class. This is generally known as calling a super method. Perls facility for doing this is butt ugly:
sub cleanup {
my $self = shift;
$self->scrub;
$self->SUPER::cleanup(@_);
}
Class::Spiffy makes it, er, super easy to call super methods. You just use the super function. You dont need to pass it any arguments because it automatically passes them on for you. Heres the same function with Class::Spiffy:
sub cleanup {
my $self = shift;
$self->scrub;
super;
}
Class::Spiffy has a special method for parsing arguments called parse_arguments, that it also uses for parsing its own arguments. You declare which arguments are boolean (singletons) and which ones are paired, with two special methods called boolean_arguments and paired_arguments. Parse arguments pulls out the booleans and pairs and returns them in an anonymous hash, followed by a list of the unmatched arguments.
Finally, Class::Spiffy can export a few debugging functions WWW, XXX, YYY and ZZZ. Each of them produces a YAML dump of its arguments. WWW warns the output, XXX dies with the output, YYY prints the output, and ZZZ confesses the output. If YAML doesnt suit your needs, you can switch all the dumps to Data::Dumper format with the - dumper option.
Download (0.024MB)
Added: 2007-06-19 License: Perl Artistic License Price:
857 downloads
HTTP::Server::Simple::Recorder 0.02
HTTP::Server::Simple::Recorder is Perl module for mixin to record HTTP::Server::Simples sockets. more>>
HTTP::Server::Simple::Recorder is Perl module for mixin to record HTTP::Server::Simples sockets.
SYNOPSIS
package MyServer;
use base qw/HTTP::Server::Simple::Recorder HTTP::Server::Simple::CGI/;
sub recorder_prefix { "path/to/logs/record" } # defaults to /tmp/http-server-simple-recorder
# logs to path/to/logs/record.34244.1.in,
# path/to/logs/record.34244.1.out,
# path/to/logs/record.34244.2.in,
# path/to/logs/record.34244.2.out, etc, if 34244 is the PID of the server
This module allows you to record all HTTP communication between an HTTP::Server::Simple-derived server and its clients. It is a mixin, so it doesnt itself subclass HTTP::Server::Simple; you need to subclass from both HTTP::Server::Simple::Recorder and an actual HTTP::Server::Simple subclass, and HTTP::Server::Simple::Recorder should be listed first.
Every time a client connects to your server, this module will open a pair of files and log the communication between the file and server to these files. Each connection gets a serial number starting at 1. The filename used is >, then a period, then the connection serial number, then a period, then either "in" or "out". recorder_prefix defaults to /tmp/http-server-simple-recorder, but you can override that in your subclass. For example, you might want to include the process ID.
<<lessSYNOPSIS
package MyServer;
use base qw/HTTP::Server::Simple::Recorder HTTP::Server::Simple::CGI/;
sub recorder_prefix { "path/to/logs/record" } # defaults to /tmp/http-server-simple-recorder
# logs to path/to/logs/record.34244.1.in,
# path/to/logs/record.34244.1.out,
# path/to/logs/record.34244.2.in,
# path/to/logs/record.34244.2.out, etc, if 34244 is the PID of the server
This module allows you to record all HTTP communication between an HTTP::Server::Simple-derived server and its clients. It is a mixin, so it doesnt itself subclass HTTP::Server::Simple; you need to subclass from both HTTP::Server::Simple::Recorder and an actual HTTP::Server::Simple subclass, and HTTP::Server::Simple::Recorder should be listed first.
Every time a client connects to your server, this module will open a pair of files and log the communication between the file and server to these files. Each connection gets a serial number starting at 1. The filename used is >, then a period, then the connection serial number, then a period, then either "in" or "out". recorder_prefix defaults to /tmp/http-server-simple-recorder, but you can override that in your subclass. For example, you might want to include the process ID.
Download (0.011MB)
Added: 2007-01-25 License: Perl Artistic License Price:
1005 downloads
Sprog 0.14
Sprog is a graphical tool that anyone can use to build programs by plugging parts together. more>>
Sprog is a graphical tool that anyone can use to build programs by plugging parts together. In Sprog jargon, the parts are known as gears and they are assembled to make a machine.
Gears are selected from a palette and dragged onto the Sprog workbench, where they can be connected together.
Options can be set using a properties dialog on each gear. When assembly is complete, the machine can be run, reconfigured, or re-run.
Enhancements:
- fix bug: machine not stopping after syntax error in Perl gear
- fix bug: broken cancel button in tools/prefs dialog
- fix bug: extra file_end events from command_filter
- fix Enter for default in file dialogs
- add ability to rename gears
- make gear title and text window fonts configurable
- make right click menu stay visible on click-release
- implement filename = - for STDIN in ReadFile.pm
- rename mixin classes from Sprog::Gear::* to Sprog::Mixin::*
<<lessGears are selected from a palette and dragged onto the Sprog workbench, where they can be connected together.
Options can be set using a properties dialog on each gear. When assembly is complete, the machine can be run, reconfigured, or re-run.
Enhancements:
- fix bug: machine not stopping after syntax error in Perl gear
- fix bug: broken cancel button in tools/prefs dialog
- fix bug: extra file_end events from command_filter
- fix Enter for default in file dialogs
- add ability to rename gears
- make gear title and text window fonts configurable
- make right click menu stay visible on click-release
- implement filename = - for STDIN in ReadFile.pm
- rename mixin classes from Sprog::Gear::* to Sprog::Mixin::*
Download (0.24MB)
Added: 2005-07-28 License: GPL (GNU General Public License) Price:
1548 downloads
Rose::DB::Object::Helpers 0.764
Rose::DB::Object::Helpers is a mix-in class containing convenience methods for Rose::DB::Object. more>>
Rose::DB::Object::Helpers is a mix-in class containing convenience methods for Rose::DB::Object.
SYNOPSIS
package MyDBObject;
use Rose::DB::Object;
our @ISA = qw(Rose::DB::Object);
use Rose::DB::Object::Helpers clone,
{ load_or_insert => find_or_create };
...
$obj = MyDBObject->new(id => 123);
$obj->find_or_create();
$obj2 = $obj->clone;
Rose::DB::Object::Helpers provides convenience methods from use with Rose::DB::Object-derived classes. These methods do not exist in Rose::DB::Object in order to keep the method namespace clean. (Each method added to Rose::DB::Object is another potential naming conflict with a column accessor.)
This class inherits from Rose::DB::Object::MixIn. See the Rose::DB::Object::MixIn documentation for a full explanation of how to import methods from this class. The helper methods themselves are described below.
<<lessSYNOPSIS
package MyDBObject;
use Rose::DB::Object;
our @ISA = qw(Rose::DB::Object);
use Rose::DB::Object::Helpers clone,
{ load_or_insert => find_or_create };
...
$obj = MyDBObject->new(id => 123);
$obj->find_or_create();
$obj2 = $obj->clone;
Rose::DB::Object::Helpers provides convenience methods from use with Rose::DB::Object-derived classes. These methods do not exist in Rose::DB::Object in order to keep the method namespace clean. (Each method added to Rose::DB::Object is another potential naming conflict with a column accessor.)
This class inherits from Rose::DB::Object::MixIn. See the Rose::DB::Object::MixIn documentation for a full explanation of how to import methods from this class. The helper methods themselves are described below.
Download (0.47MB)
Added: 2007-07-18 License: Perl Artistic License Price:
828 downloads
Scala 2.5.1 / 2.6.0 RC1
Scala is a modern multi-paradigm programming language. more>>
Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way.
Scala smoothly integrates features of object-oriented and functional languages including mixins, algebraic datatypes with pattern matching, genericity, and more.
It is well integrated with Java and .NET: the Scala compiler produces standard Java class files or .NET assemblies, and Java/.NET libraries and frameworks can be used without glue code or additional declarations.
Scala is a pure object-oriented language in the sense that every value is an object. Types and behavior of objects are described by classes and traits. Class abstractions are extended by subclassing and a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance.
Whats New in 2.6.0 RC1 Development Release:
- This version introduces some language changes (existential types, lazy values, structural types, etc.) and fixes many bugs.
<<lessScala smoothly integrates features of object-oriented and functional languages including mixins, algebraic datatypes with pattern matching, genericity, and more.
It is well integrated with Java and .NET: the Scala compiler produces standard Java class files or .NET assemblies, and Java/.NET libraries and frameworks can be used without glue code or additional declarations.
Scala is a pure object-oriented language in the sense that every value is an object. Types and behavior of objects are described by classes and traits. Class abstractions are extended by subclassing and a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance.
Whats New in 2.6.0 RC1 Development Release:
- This version introduces some language changes (existential types, lazy values, structural types, etc.) and fixes many bugs.
Download (13.2MB)
Added: 2007-07-28 License: BSD License Price:
825 downloads
Other version of Scala
License:BSD License
Closure::Loop 0.0.2
Closure::Loop is a Perl module with redo, last, next for closure based loops. more>>
Closure::Loop is a Perl module with redo, last, next for closure based loops.
SYNOPSIS
package MyIterator;
use Closure::Loop; # mixin
sub new {
my $class = shift;
return bless { }, $class;
}
sub forAll {
my $self = shift;
my $cb = pop || die "No callback";
for my $i (@_) {
eval {
$self->yield($cb, $i);
};
last if $self->is_last;
die $@ if $@;
}
}
package main;
my $iter = MyIterator->new();
my @in = ( 1, 2, 3 );
my @out = ( );
$iter->forAll(@in, sub {
my $i = shift;
$iter->next if $i == 2; # skip value
push @out, $i;
});
# @out is ( 1, 3 )
An idea that Perl programmers can usefully borrow from Ruby is the concept of synthesizing new looping constructs by passing a block of code to a function that repeatedly calls it with successive values in a sequence.
In Ruby this looks like this:
def count_to_ten
i = 1
while i<<less
SYNOPSIS
package MyIterator;
use Closure::Loop; # mixin
sub new {
my $class = shift;
return bless { }, $class;
}
sub forAll {
my $self = shift;
my $cb = pop || die "No callback";
for my $i (@_) {
eval {
$self->yield($cb, $i);
};
last if $self->is_last;
die $@ if $@;
}
}
package main;
my $iter = MyIterator->new();
my @in = ( 1, 2, 3 );
my @out = ( );
$iter->forAll(@in, sub {
my $i = shift;
$iter->next if $i == 2; # skip value
push @out, $i;
});
# @out is ( 1, 3 )
An idea that Perl programmers can usefully borrow from Ruby is the concept of synthesizing new looping constructs by passing a block of code to a function that repeatedly calls it with successive values in a sequence.
In Ruby this looks like this:
def count_to_ten
i = 1
while i<<less
Download (0.006MB)
Added: 2007-01-18 License: Perl Artistic License Price:
1009 downloads
Secleted [ 0 ] software to compare
- Page: 1 of 2
- 1
- 2
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above mixin search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed