package Fun; use strict; use warnings; # ABSTRACT: simple function signatures use Devel::CallParser; use XSLoader; XSLoader::load( __PACKAGE__, exists $Fun::{VERSION} ? ${ $Fun::{VERSION} } : (), ); use Exporter 'import'; our @EXPORT = our @EXPORT_OK = ('fun'); =head1 SYNOPSIS use Fun; fun float_eq ($a, $b, $e = 0.0001) { return abs($a - $b) < $e; } =head1 DESCRIPTION This module provides C, a new keyword which defines functions the same way that C does, except allowing for function signatures. These signatures support defaults and slurpy arguments, but no other advanced features. The behavior should be equivalent to taking the signature, stripping out the defaults, and injecting C<< my = @_ >> at the start of the function, and then applying defaults as appropriate, except that the arguments are made readonly. =cut =head1 EXPORTS =head2 fun Behaves identically to C, except that it does not support prototypes or attributes, but it does support a simple function signature. This signature consists of a comma separated list of variables, each variable optionally followed by C<=> and an expression to use for a default. For instance: fun foo ($x, $y = 5) { ... } Defaults are evaluated every time the function is called, so global variable access and things of that sort should work correctly. C supports creating both named and anonymous functions, just as C does. =cut sub fun { my ($code) = @_; return $code; } =head1 BUGS No known bugs. Please report any bugs through RT: email C, or browse to L. =head1 SEE ALSO L, etc... =head1 SUPPORT You can find this documentation for this module with the perldoc command. perldoc Fun You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =cut 1;