Syntax::Feature::Function - Provides a function keyword
version 0.001
package Foo; use syntax 'function'; fun curry ($orig, @orig_args) { fun (@args) { $orig->(@orig_args, @args) } } curry(fun ($n, $m) { $n + $m }, 2)->(3); # 5 1;
This library uses the syntax dispatching mechanism to activate the functionality provided by Function::Parameters.
By default, a fun keyword will be provided. There are various ways to change the name and number of function keywords that will be provided.
fun
use syntax function => { -as => 'f' };
The above example would provide a function declaration keyword named f instead of fun. So you could say
f
f foo ($n) { 2 * $n }
and
f ($n) { 2 * $n }
for anonymous functions.
use syntax function => { -as => [qw( f fun )] };
This usage will provide you with both keywords: f and fun. They will both work the same way.
Called by syntax to install the function declarator keyword into the requesting package.
syntax, Function::Parameters, Devel::Declare
Robert 'phaylon' Sedlacek <rs@474.at>
This software is copyright (c) 2010 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.
To install Syntax::Feature::Function, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Syntax::Feature::Function
CPAN shell
perl -MCPAN -e shell install Syntax::Feature::Function
For more information on module installation, please visit the detailed CPAN module installation guide.