This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Patch from MHX to change the WriteConstant()'s documentation to note
[perl5.git] / lib / Memoize.pm
index 9f5c591..a7f29de 100644 (file)
@@ -8,10 +8,10 @@
 # same terms as Perl itself.  If in doubt, 
 # write to mjd-perl-memoize+@plover.com for a license.
 #
-# Version 1.00 $Revision: 1.18 $ $Date: 2001/06/24 17:16:47 $
+# Version 1.01 $Revision: 1.18 $ $Date: 2001/06/24 17:16:47 $
 
 package Memoize;
-$VERSION = '1.00';
+$VERSION = '1.01_02';
 
 # Compile-time constants
 sub SCALAR () { 0 } 
@@ -167,8 +167,6 @@ sub memoize {
   $wrapper                     # Return just memoized version
 }
 
-use warnings::register;
-
 # This function tries to load a tied hash class and tie the hash to it.
 sub _my_tie {
   my ($context, $hash, $options) = @_;
@@ -179,7 +177,7 @@ sub _my_tie {
   
   return unless defined $shortopt && $shortopt eq 'TIE';
   carp("TIE option to memoize() is deprecated; use HASH instead")
-      if warnings::enabled('deprecated');
+      if $^W;
 
   my @args = ref $fullopt ? @$fullopt : ();
   shift @args;
@@ -268,8 +266,9 @@ sub _memoizer {
       # Otherwise, we cached an array containing the returned list:
       return @$val;
     } else {
-      my $q = $cache->{$argstr} = [&{$info->{U}}(@_)];
-      @$q;
+        my @q = &{$info->{U}}(@_);
+        $cache->{$argstr} = $info->{O}{LIST_CACHE} eq 'MERGE' ? $q [0] : \@q;
+        @q;
     }
   } else {
     croak "Internal error \#42; context was neither LIST nor SCALAR\n";
@@ -363,7 +362,7 @@ Memoize - Make functions faster by trading space for time
 
 =head1 SYNOPSIS
 
-        # This is the documentation for Memoize 1.00
+        # This is the documentation for Memoize 1.01
        use Memoize;
        memoize('slow_function');
        slow_function(arguments);    # Is faster than it was before
@@ -1004,11 +1003,10 @@ memoization and about the internals of Memoize that appeared in The
 Perl Journal, issue #13.  (This article is also included in the
 Memoize distribution as `article.html'.)
 
-My upcoming book will discuss memoization (and many other fascinating
-topics) in tremendous detail.  It will be published by Morgan Kaufmann
-in 2002, possibly under the title I<Perl Advanced Techniques
-Handbook>.  It will also be available on-line for free.  For more
-information, visit http://perl.plover.com/book/ .
+The author's book I<Higher Order Perl> (2005, ISBN 1558607013, published
+by Morgan Kaufmann) discusses memoization (and many other fascinating
+topics) in tremendous detail. It will also be available on-line for free.
+For more information, visit http://perl.plover.com/book/ .
 
 To join a mailing list for announcements about C<Memoize>, send an
 empty message to C<mjd-perl-memoize-request@plover.com>.  This mailing