]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - lib/Variable/Magic.pm
A few doc corrections
[perl/modules/Variable-Magic.git] / lib / Variable / Magic.pm
index 05fb3642bf72cc27a16ebd61021b9d23550d518d..bdbb97e8acc365adb5144d31aa3a5e85009b36b9 100644 (file)
@@ -13,13 +13,13 @@ Variable::Magic - Associate user-defined magic to variables from Perl.
 
 =head1 VERSION
 
-Version 0.38
+Version 0.40
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.38';
+ $VERSION = '0.40';
 }
 
 =head1 SYNOPSIS
@@ -50,8 +50,8 @@ BEGIN {
 
 =head1 DESCRIPTION
 
-Magic is Perl way of enhancing objects.
-This mechanism lets the user add extra data to any variable and hook syntaxical operations (such as access, assignment or destruction) that can be applied to it.
+Magic is Perl's way of enhancing variables.
+This mechanism lets the user add extra data to any variable and hook syntactical operations (such as access, assignment or destruction) that can be applied to it.
 With this module, you can add your own magic to any variable without having to write a single line of XS.
 
 You'll realize that these magic variables look a lot like tied variables.
@@ -72,7 +72,7 @@ You attach it to variables, not values (as for blessed references).
 
 It doesn't replace the original semantics.
 
-Magic callbacks usually trigger before the original action take place, and can't prevent it to happen.
+Magic callbacks usually get triggered before the original action takes place, and can't prevent it from happening.
 This also makes catching individual events easier than with C<tie>, where you have to provide fallbacks methods for all actions by usually inheriting from the correct C<Tie::Std*> class and overriding individual methods in your own class.
 
 =item *
@@ -417,7 +417,8 @@ Value to pass with C<op_info> to get a C<B::OP> object representing the current
 
 =head2 Associate an object to any perl variable
 
-This can be useful for passing user data through limited APIs.
+This technique can be useful for passing user data through limited APIs.
+It is similar to using inside-out objects, but without the drawback of having to implement a complex destructor.
 
     {
      package Magical::UserData;
@@ -430,9 +431,9 @@ This can be useful for passing user data through limited APIs.
       my ($var) = @_;
       my $data = &getdata($var, $wiz);
       unless (defined $data) {
-       &cast($var, $wiz);
-       $data = &getdata($var, $wiz);
-       die "Couldn't cast UserData magic onto the variable" unless defined $data;
+       $data = \(my $slot);
+       &cast($var, $wiz, $slot)
+                        or die "Couldn't cast UserData magic onto the variable";
       }
       $$data;
      }
@@ -623,7 +624,7 @@ Tests code coverage report is available at L<http://www.profvince.com/perl/cover
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007-2009 Vincent Pit, all rights reserved.
+Copyright 2007,2008,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.