NAME
Syntax::Feature::Simple::V1 - Version 1 of bundled syntax enhancements
VERSION
version 0.001
SYNOPSIS
use syntax qw( simple/v1 );
DESCRIPTION
This is the first version (v1
) of simple syntax extensions. It will setup common syntax extensions for Moose classes, roles, parameterized roles implemented via MooseX::Role::Parameterized and plain Perl packages.
Moose Classes and Roles
If a Moose class or role is detected, this extension will setup a fun
keyword for function declarations, a method
keyword, and one keyword each for before
, after
and around
.
The modifiers behave exactly like normal method declarations, except for around
which will provide the original method in a lexical named $orig
.
package MyProject::MooseClassOrRole;
use Moose;
# or use Moose::Role
# or use MooseX::Role::Parameterized,
# but with body inside role { ... };
use syntax qw( simple/v1 );
fun foo ($x) { ... }
my $anon_f = fun ($x) { ... };
method bar ($x) { $self->say($x) }
my $anon_m = method ($x) { $self->say($x) };
before baz ($x) { $self->say($x) }
after baz ($x) { $self->say($x) }
around baz ($x) { $self->say($self->$orig($x)) }
1;
In case of a parameterizable role the right callback will be called, but compatibility with anonymous method declarations will be preserved:
package MyProject::ParamRole;
use MooseX::Role::Parameterized;
use syntax qw( simple/v1 );
parameter method_name => (is => 'ro');
role {
my $name = $_[0]->method_name;
method "$name" ($n) { $self->say($n) }
my $anon = method ($n) { $self->say($n) };
};
1;
Plain Packages
By default, if no other kind of package type is detected, only the function syntax extension will be exported.
package MyProject::Util;
use strictures 1;
use syntax qw( simple/v1 );
fun foo ($x) { ... }
my $anon = fun ($x) { ... };
1;
METHODS
install
$class->install(into => $target);
Called by syntax dispatcher to install the extension into a target package.
SEE ALSO
- Syntax::Feature::Simple
-
Contains general information about this extension.
- Syntax::Feature::Method
-
Specifics about the
method
and modifier keywords. - Syntax::Feature::Function
-
Specifics about the
fun
function keyword. - Moose
-
Post-modern object-orientation.
BUGS
Please report any bugs or feature requests to bug-syntax-feature-simple@rt.cpan.org or through the web interface at: http://rt.cpan.org/Public/Dist/Display.html?Name=Syntax-Feature-Simple
AUTHOR
Robert 'phaylon' Sedlacek <rs@474.at>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Robert 'phaylon' Sedlacek.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.