From: Vincent Pit Date: Mon, 29 Sep 2008 19:35:59 +0000 (+0200) Subject: A little paragraph on how magic is cool X-Git-Tag: v0.22~1 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=71cf3d2bf5d004e5feeb58e20b867e66e7f840b9;p=perl%2Fmodules%2FVariable-Magic.git A little paragraph on how magic is cool --- diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index 366c204..f7e5792 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -35,7 +35,29 @@ BEGIN { =head1 DESCRIPTION -Magic is Perl way of enhancing objects. This mechanism let the user add extra data to any variable and overload syntaxical operations (such as access, assignation or destruction) that can be applied to it. With this module, you can add your own magic to any variable without the pain of the C API. +Magic is Perl way of enhancing objects. This mechanism let the user add extra data to any variable and hook syntaxical operations (such as access, assignation or destruction) that can be applied to it. With this module, you can add your own magic to any variable without the pain of the C API. + +Magic differs from tieing and overloading in several ways : + +=over 4 + +=item * + +Magic isn't copied on assignation (as for blessed references) : you attach it to variables, not values. + +=item * + +It doesn't replace the original semantics : magic callbacks trigger before the original action take place, and can't prevent it to happen. + +=item * + +It's mostly invisible at the Perl level : magical and non-magical variables cannot be distinguished with C, C or another trick. + +=item * + +It's notably faster, since perl's way of handling magic is lighter by nature, and there's no need for any method resolution. + +=back The operations that can be overloaded are :