]> git.vpit.fr Git - perl/modules/autovivification.git/blobdiff - lib/autovivification.pm
This is 0.06
[perl/modules/autovivification.git] / lib / autovivification.pm
index ac9bd98f0231308244a657d081563fcb0838bc45..01caf24e998939bac293c7742712523b0ce042d7 100644 (file)
@@ -11,13 +11,13 @@ autovivification - Lexically disable autovivification.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.06
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.01';
+ $VERSION = '0.06';
 }
 
 =head1 SYNOPSIS
@@ -65,6 +65,7 @@ Enables the features given in C<@opts>, which can be :
 C<'fetch'>
 
 Turn off autovivification for rvalue dereferencing expressions, such as C<< $value = $hashref->{key}[$idx]{$field} >>, C<< keys %{$hashref->{key}} >> or C<< values %{$hashref->{key}} >>.
+Starting from perl C<5.11>, it also covers C<keys> and C<values> on array references.
 When the expression would have autovivified, C<undef> is returned for a plain fetch, while C<keys> and C<values> return C<0> in scalar context and the empty list in list context.
 
 =item *
@@ -85,7 +86,7 @@ C<undef> is returned when the expression would have autovivified.
 
 C<'store'>
 
-Turn off autovivification for lvalue dereferencing expressions, such as C<< $hashref->{key}[$idx]{$field} = $value >>.
+Turn off autovivification for lvalue dereferencing expressions, such as C<< $hashref->{key}[$idx]{$field} = $value >> or C<< for ($hashref->{key}[$idx]{$field}) { ... } >>.
 An exception is thrown if vivification is needed to store the value, which means that effectively you can only assign to levels that are already defined (in the example, this would require C<< $hashref->{key}[$idx] >> to already be a hash reference).
 
 =item *
@@ -150,6 +151,24 @@ sub import {
  ();
 }
 
+=head1 CONSTANTS
+
+=head2 C<A_THREADSAFE>
+
+True iff the module could have been built with thread-safety features enabled.
+This constant only has a meaning with your perl is threaded ; otherwise, it'll always be false.
+
+=head2 C<A_FORKSAFE>
+
+True iff this module could have been built with fork-safety features enabled.
+This will always be true except on Windows where it's false for perl 5.10.0 and below .
+
+=head1 CAVEATS
+
+The pragma doesn't apply when one dereferences the returned value of an array or hash slice, as in C<< @array[$id]->{member} >> or C<< @hash{$key}->{member} >>.
+This syntax is valid Perl, yet it's discouraged as the slice is here useless since the dereferencing enforces scalar context.
+If warnings are turned on, Perl will complain about one-element slices.
+
 =head1 DEPENDENCIES
 
 L<perl> 5.8.
@@ -185,7 +204,7 @@ Matt S. Trout asked for it.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2009 Vincent Pit, all rights reserved.
+Copyright 2009,2010 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.