Aspect
view release on metacpan or search on metacpan
} call 'Van::compute_mileage';
Some join points one would expect to be matched by the call pointcuts
above, do not:
$automobile = Automobile->new;
$van = Van->new;
$automobile->compute_mileage; # Automobile!
$van->compute_mileage; # Automobile!, should also print Van!
"Van!" will never be printed. This happens because Aspect installs
advice code on symbol table entries. "Van::compute_mileage" does not
have one, so nothing happens. Until this is solved, you have to do the
thinking about inheritance yourself.
Performance
You may find it very easy to shoot yourself in the foot with this
module. Consider this advice:
# Do not do this!
before {
print $_->sub_name;
} cflow 'MyApp::Company::make_report';
The advice code will be installed on every sub loaded. The advice code
will only run when in the specified call flow, which is the correct
behavior, but it will be *installed* on every sub in the system. This
can be extremely slow because the run-time cost of checking "cflow" will
occur on every single function called in your program.
It happens because the "cflow" pointcut matches *all* subs during
weave-time. It matches the correct sub during run-time. The solution is
to narrow the pointcut:
# Much better
before {
print $_->sub_name;
} call qr/^MyApp::/
& cflow 'MyApp::Company::make_report';
TO DO
There are a many things that could be added, if people have an interest
in contributing to the project.
Documentation
* cookbook
* tutorial
* example of refactoring a useful CPAN module using aspects
Pointcuts
* New pointcuts: execution, cflowbelow, within, advice, calledby. Sure
you can implement them today with Perl treachery, but it is too much
work.
* We need a way to match subs with an attribute, attributes::get() will
currently not work.
* isa() support for method pointcuts as Gaal Yahas suggested: match
methods on class hierarchies without callbacks
* Perl join points: phasic- BEGIN/INIT/CHECK/END
Weaving
* The current optimation has gone as far as it can, next we need to look
into XS acceleration and byte code manipulation with B:: modules.
* A debug flag to print out subs that were matched during weaving
* Warnings when over 1000 methods wrapped
* Allow finer control of advice execution order
* Centralised hooking in wrappers so that each successive advice won't
need to wrap around the previous one.
* Allow lexical aspects to be safely removed completely, rather than
being left in place and disabled as in the current implementation.
SUPPORT
Please report any bugs or feature requests through the web interface at
<http://rt.cpan.org/Public/Dist/Display.html?Name=Aspect>.
INSTALLATION
See perlmodinstall for information and options on installing Perl
modules.
AVAILABILITY
The latest version of this module is available from the Comprehensive
Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a
CPAN site near you. Or see <http://search.cpan.org/perldoc?Aspect>.
AUTHORS
Adam Kennedy <adamk@cpan.org>
Marcel Grünauer <marcel@cpan.org>
Ran Eilam <eilara@cpan.org>
SEE ALSO
You can find AOP examples in the "examples/" directory of the
distribution.
Aspect::Library::Memoize
Aspect::Library::Profiler
Aspect::Library::Trace
COPYRIGHT
Copyright 2001 by Marcel Grünauer
Some parts copyright 2009 - 2013 Adam Kennedy.
Parts of the initial introduction courtesy Wikipedia.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
( run in 0.511 second using v1.01-cache-2.11-cpan-39bf76dae61 )