Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class::mix(3pm) [debian man page]

Class::Mix(3pm) 					User Contributed Perl Documentation					   Class::Mix(3pm)

NAME
Class::Mix - dynamic class mixing SYNOPSIS
use Class::Mix qw(mix_class); $foobar_object = mix_class("Foo", "Bar")->new; use Class::Mix qw(genpkg); $package = genpkg; $package = genpkg("Digest::Foo::"); DESCRIPTION
The "mix_class" function provided by this module dynamically generates `anonymous' classes with specified inheritance. FUNCTIONS
mix_class(CLASSES ...) This function is used to dynamically generate `anonymous' classes by mixing pre-existing classes. This is useful where an incomplete class requires use of a mixin in order to become instantiable, several suitable mixins are available, and it is desired to make the choice between mixins at runtime. The function takes as its argument list the desired @ISA list of the mixture class to be created; that is, a list of names of classes to inherit from. It generates a class with the specified inheritance, and returns its name. The same class will be returned by repeated invocations with the same class list. The returned name may be used to call a constructor or other class methods of the mixed class. A class name must be returned because there is no such thing as an anonymous class in Perl. Classes are referenced by name. The names that are generated by this function are unique and insignificant. See "genpkg" below for more information. If fewer than two classes to inherit from are specified, the function does not bother to generate a new class. If only one class is specified then that class is returned. If no classes are specified then "UNIVERSAL" is returned. This provides the desired inheritance without creating superfluous classes. This function relies on the classes it returns remaining unmodified in order to be returned by future invocations. If you want to modify your dynamically-generated `anonymous' classes, use "genpkg" (below). genpkg([PREFIX]) This function selects and returns a package name that has not been previously used. The name returned is an ordinary bareword-form package name, and can be used as the second argument to "bless" and in all other ways that package names are used. The package is initially empty. The package names returned by this function are of a type that should not be used as ordinary fixed module names. However, it is not possible to entirely prevent a clash. This function checks that the package name it is about to return has not already been used, and will avoid returning such names, but it cannot guarantee that a later-loaded module will not create a clash. PREFIX, if present, specifies where the resulting package will go. It must be either the empty string (to create a top-level package) or a bareword followed by "::" (to create a package under that name). For example, "Digest::" could be specified to ensure that the resulting package has a name starting with "Digest::", so that "Digest->new" will accept it as the name of a message digest algorithm. SEE ALSO
Class::Generate AUTHOR
Andrew Main (Zefram) <zefram@fysh.org> COPYRIGHT
Copyright (C) 2004, 2006, 2009 Andrew Main (Zefram) <zefram@fysh.org> LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-03-24 Class::Mix(3pm)

Check Out this Related Man Page

base(3pm)						 Perl Programmers Reference Guide						 base(3pm)

NAME
base - Establish an ISA relationship with base classes at compile time SYNOPSIS
package Baz; use base qw(Foo Bar); DESCRIPTION
Unless you are using the "fields" pragma, consider this module discouraged in favor of the lighter-weight "parent". Allows you to both load one or more modules, while setting up inheritance from those modules at the same time. Roughly similar in effect to package Baz; BEGIN { require Foo; require Bar; push @ISA, qw(Foo Bar); } When "base" tries to "require" a module, it will not die if it cannot find the module's file, but will die on any other error. After all this, should your base class be empty, containing no symbols, "base" will die. This is useful for inheriting from classes in the same file as yourself but where the filename does not match the base module name, like so: # in Bar.pm package Foo; sub exclaim { "I can have such a thing?!" } package Bar; use base "Foo"; There is no Foo.pm, but because "Foo" defines a symbol (the "exclaim" subroutine), "base" will not die when the "require" fails to load Foo.pm. "base" will also initialize the fields if one of the base classes has it. Multiple inheritance of fields is NOT supported, if two or more base classes each have inheritable fields the 'base' pragma will croak. See fields for a description of this feature. The base class' "import" method is not called. DIAGNOSTICS
Base class package "%s" is empty. base.pm was unable to require the base package, because it was not found in your path. Class 'Foo' tried to inherit from itself Attempting to inherit from yourself generates a warning. package Foo; use base 'Foo'; HISTORY
This module was introduced with Perl 5.004_04. CAVEATS
Due to the limitations of the implementation, you must use base before you declare any of your own fields. SEE ALSO
fields perl v5.16.3 2013-03-04 base(3pm)
Man Page