C::Blocks::Filter::BlockArrowMethods - invoke methods succinctly
use strict; use warnings; use C::Blocks; use C::Blocks::Filter::BlockArrowMethods; cblock { /* These are equivalent */ a=>some_thing(arg1, arg2); a->methods->some_thing(a, arg1, arg2); }
When invoking methods on vtable-based classes, you need to extract the method by dereferencing the vtable, and then you have to pass the object as the first argument of the method. If the vtable pointer is registered under the name methods, you might invoke the method some_action as
methods
some_action
obj->methods->some_action(obj, other, args);
The C::Blocks::Filter::BlockArrowMethods filter would let you use the following more succinct statement:
C::Blocks::Filter::BlockArrowMethods
obj=>some_action(other, args);
This would be converted to the previous more verbose example.
To install C::Blocks, copy and paste the appropriate command in to your terminal.
cpanm
cpanm C::Blocks
CPAN shell
perl -MCPAN -e shell install C::Blocks
For more information on module installation, please visit the detailed CPAN module installation guide.