Fun - simple function signatures
version 0.05
use Fun; fun float_eq ($a, $b, $e = 0.0001) { return abs($a - $b) < $e; }
This module provides fun, a new keyword which defines functions the same way that sub 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 my <sig> = @_ at the start of the function, and then applying defaults as appropriate, except that the arguments are made readonly.
fun
sub
my <sig> = @_
Behaves identically to sub, 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 = 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.
fun supports creating both named and anonymous functions, just as sub does.
No known bugs.
Please report any bugs through RT: email bug-fun at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Fun.
bug-fun at rt.cpan.org
signatures, etc...
You can find this documentation for this module with the perldoc command.
perldoc Fun
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Fun
CPAN Ratings
http://cpanratings.perl.org/d/Fun
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Fun
Search CPAN
http://search.cpan.org/dist/Fun
Jesse Luehrs <doy at cpan dot org>
This software is Copyright (c) 2012 by Jesse Luehrs.
This is free software, licensed under:
The MIT (X11) License
To install Fun, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fun
CPAN shell
perl -MCPAN -e shell install Fun
For more information on module installation, please visit the detailed CPAN module installation guide.