]> git.vpit.fr Git - perl/modules/Sub-Prototype-Util.git/commitdiff
This is 0.09 v0.09
authorVincent Pit <vince@profvince.com>
Thu, 4 Jun 2009 22:42:00 +0000 (00:42 +0200)
committerVincent Pit <vince@profvince.com>
Thu, 4 Jun 2009 22:42:00 +0000 (00:42 +0200)
Changes
META.yml
README
lib/Sub/Prototype/Util.pm

diff --git a/Changes b/Changes
index 15a567f5c58ed8725c2b0f284a84a5e9603971f6..e32b0d1d36c8461d4c1c23d8c534f0093274528a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,14 @@
 Revision history for Sub-Prototype-Util
 
+0.09    2009-06-04 22:45 UTC
+        + Chg : recall() was reimplemented in terms of wrap().
+        + Chg : "compile => 1" is now the default for wrap.
+        + Fix : Croak messages are now relative to the caller.
+        + Fix : flatten() croaks when not enough arguments were given to match
+                the prototype.
+        + Upd : Resources in META.yml.
+        + Upd : META.yml spec updated to 1.4.
+
 0.08    2008-05-02 15:25 UTC
         + Fix : "{ $func => undef }" (resp. "=> ''") should enforce no prototype
                 (resp. enforce an empty prototype).
index dfa711fe3e75eeb770197d4b1bfa4a42f2730888..6f11b409ae13eb7b3901efe9a63df6a5546027e9 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,20 +1,32 @@
 --- #YAML:1.0
-name:                Sub-Prototype-Util
-version:             0.08
-abstract:            Prototype-related utility routines.
-license:             perl
-author:              
+name:               Sub-Prototype-Util
+version:            0.09
+abstract:           Prototype-related utility routines.
+author:
     - Vincent Pit <perl@profvince.com>
-generated_by:        ExtUtils::MakeMaker version 6.44
-distribution_type:   module
-requires:     
-    Carp:                          0
-    Exporter:                      0
-    Scalar::Util:                  0
-meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
 build_requires:
-    ExtUtils::MakeMaker:           0
-    Scalar::Util:                  0
-    Test::More:                    0
+    ExtUtils::MakeMaker:  0
+    Scalar::Util:         0
+    Test::More:           0
+requires:
+    Carp:          0
+    Exporter:      0
+    perl:          5.006
+    Scalar::Util:  0
+resources:
+    bugtracker:  http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-Prototype-Util
+    homepage:    http://search.cpan.org/dist/Sub-Prototype-Util/
+    license:     http://dev.perl.org/licenses/
+    repository:  http://git.profvince.com/?p=perl%2Fmodules%2FSub-Prototype-Util.git
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.52
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4
diff --git a/README b/README
index 316b1f609e8360c89476d3912457e8a9264c13d8..04da32e0b5761ce7e981ac4be67ba05c0194be4a 100644 (file)
--- a/README
+++ b/README
@@ -2,17 +2,17 @@ NAME
     Sub::Prototype::Util - Prototype-related utility routines.
 
 VERSION
-    Version 0.08
+    Version 0.09
 
 SYNOPSIS
-        use Sub::Prototype::Util qw/flatten recall wrap/;
+        use Sub::Prototype::Util qw/flatten wrap recall/;
 
         my @a = qw/a b c/;
         my @args = ( \@a, 1, { d => 2 }, undef, 3 );
 
         my @flat = flatten '\@$;$', @args; # ('a', 'b', 'c', 1, { d => 2 })
         recall 'CORE::push', @args; # @a contains 'a', 'b', 'c', 1, { d => 2 }, undef, 3
-        my $splice = wrap 'CORE::splice', compile => 1;
+        my $splice = wrap 'CORE::splice';
         my @b = $splice->(\@a, 4, 2); # @a is now ('a', 'b', 'c', 1, 3) and @b is ({ d => 2 }, undef)
 
 DESCRIPTION
@@ -28,39 +28,28 @@ FUNCTIONS
     Flattens the array @args according to the prototype $proto. When @args
     is what @_ is after calling a subroutine with prototype $proto,
     "flatten" returns the list of what @_ would have been if there were no
-    prototype.
+    prototype. It croaks if the arguments can't possibly match the required
+    prototype, e.g. when a reference type is wrong or when not enough
+    elements were provided.
 
-  "recall $name, @args"
-    Calls the function $name with the prototyped argument list @args. That
-    is, @args should be what @_ is when you define a subroutine with the
-    same prototype as $name. For example,
-
-        my $a = [ ];
-        recall 'CORE::push', $a, 1, 2, 3;
+  "wrap $name, %opts"
+    Generates a wrapper that calls the function $name with a prototyped
+    argument list. That is, the wrapper's arguments should be what @_ is
+    when you define a subroutine with the same prototype as $name.
 
-    will call "push @$a, 1, 2, 3" and so fill the arrayref $a with "1, 2,
-    3". This is especially needed for core functions because you can't
-    "goto" into them.
+        my $a = [ 0 .. 2 ];
+        my $push = wrap 'CORE::push';
+        $push->($a, 3, 4); # returns 3 + 2 = 5 and $a now contains 0 .. 4
 
-    You can also force the use of a specific prototype. In this case, $name
-    must be a hash reference that holds exactly one key/value pair, the key
+    You can force the use of a specific prototype. In this case, $name must
+    be a hash reference that holds exactly one key / value pair, the key
     being the function name and the value the prototpye that should be used
     to call it.
 
-        recall { 'CORE::push' => '\@$' }, $a, 1, 2, 3; # will only push 1
-
-    This allows you to recall into "CORE::grep" and "CORE::map" by using the
-    "\&@" prototype :
-
-        sub mygrep (&@) { recall { 'CORE::grep' => '\&@' }, @_ } # the prototypes are intentionally different
+        my $push = wrap { 'CORE::push' => '\@$' }; # only pushes 1 arg
 
-  "wrap $name, %opts"
-    Generates a wrapper that does the same thing as "recall", but
-    specialized for a given function. This wrapper can be compiled once for
-    all to avoid calling "eval" at each run (like "recall" does). You can
-    still force the prototype by passing "{ $name => $proto }" as the first
-    argument. Others arguments are seen as key / value pairs and tune the
-    code generated by "wrap". Valid keys are :
+    Others arguments are seen as key / value pairs that are meant to tune
+    the code generated by "wrap". Valid keys are :
 
     "ref => $func"
         Specifies the function used in the generated code to test the
@@ -78,17 +67,30 @@ FUNCTIONS
 
     "compile => $bool"
         Makes "wrap" compile the code generated and return the resulting
-        code reference. Implies "sub => 1". Be careful that in this case
-        "ref" must be a fully qualified function name. Defaults to false.
+        code reference. Be careful that in this case "ref" must be a fully
+        qualified function name. Defaults to true, but turned off when "sub"
+        is false.
+
+    For example, this allows you to recall into "CORE::grep" and "CORE::map"
+    by using the "\&@" prototype :
 
-    This is how you make your own "push" that pushes into array references :
+        my $grep = wrap { 'CORE::grep' => '\&@' };
+        sub mygrep (&@) { $grep->(@_) } # the prototypes are intentionally different
+
+  "recall $name, @args"
+    Calls the function $name with the prototyped argument list @args. That
+    is, @args should be what @_ is when you call a subroutine with $name as
+    prototype. You can still force the prototype by passing "{ $name =>
+    $proto }" as the first argument.
+
+        my $a = [ ];
+        recall { 'CORE::push' => '\@$' }, $a, 1, 2, 3; # $a just contains 1
 
-        my @a = (0 .. 2);
-        my $push = wrap 'CORE::push', compile => 1;
-        $push->(\@a, 3 .. 7); # returns 3 + 5 = 8, and @a now contains 0 .. 7
+    It's implemented in terms of "wrap", and hence calls "eval" at each run.
+    If you plan to recall several times, consider using "wrap" instead.
 
 EXPORT
-    The functions "flatten", "recall" and "wrap" are only exported on
+    The functions "flatten", "wrap" and "recall" are only exported on
     request, either by providing their name or by the ':funcs' and ':all'
     tags.
 
@@ -98,8 +100,7 @@ DEPENDENCIES
 AUTHOR
     Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
 
-    You can contact me by mail or on #perl @ FreeNode (vincent or
-    Prof_Vince).
+    You can contact me by mail or on "irc.perl.org" (vincent).
 
 BUGS
     Please report any bugs or feature requests to "bug-sub-prototype-util at
@@ -117,7 +118,7 @@ SUPPORT
     <http://www.profvince.com/perl/cover/Sub-Prototype-Util>.
 
 COPYRIGHT & LICENSE
-    Copyright 2008 Vincent Pit, all rights reserved.
+    Copyright 2008-2009 Vincent Pit, all rights reserved.
 
     This program is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.
index d88c553c37856dd275f68b18e395fefe443c99fc..4297c264fc72de4e28b7aeec23189e6743d2963c 100644 (file)
@@ -14,13 +14,13 @@ Sub::Prototype::Util - Prototype-related utility routines.
 
 =head1 VERSION
 
-Version 0.08
+Version 0.09
 
 =cut
 
 use vars qw/$VERSION/;
 
-$VERSION = '0.08';
+$VERSION = '0.09';
 
 =head1 SYNOPSIS