[Catalyst-commits] r9032 - Catalyst-Runtime/5.80/trunk/lib/Catalyst

groditi at dev.catalyst.perl.org groditi at dev.catalyst.perl.org
Wed Jan 7 21:06:23 GMT 2009


Author: groditi
Date: 2009-01-07 21:06:23 +0000 (Wed, 07 Jan 2009)
New Revision: 9032

Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Upgrading.pod
Log:
added doc bit about anon subrefs in the symbol table

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Upgrading.pod
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Upgrading.pod	2009-01-07 19:51:06 UTC (rev 9031)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Upgrading.pod	2009-01-07 21:06:23 UTC (rev 9032)
@@ -19,6 +19,28 @@
 
 rafl to fix this bit :)
 
+=head2 Anonymous closures installed directly into the symbol table
+
+If you have any code which installs anonymous subroutine references directly
+into the symbol table, you may encounter breakages. The simplest solution is
+to use L<Sub::Name> to name the subroutine. Example:
+
+    #Originalcode, likely to break:
+    my $full_method_name = join('::',$package_name, $method_name);
+    *$full_method_name = sub { ... };
+
+    #Fixed Code
+    use Sub::Name 'subname';
+    my $full_method_name = join('::',$package_name, $method_name);
+    *$full_method_name = subname $full_method_name, sub { ... };
+
+Additionally, you can take advantage of Catalyst's use of L<Class::MOP> and
+install the closure using the appropriate metaclass. Example:
+
+    use Class::MOP;
+    my $metaclass = Moose::Meta::Class->initialize($package_name);
+    $metaclass->add_method($method_name => sub { ... });
+
 =head2 Components without new methods
 
 FIXME




More information about the Catalyst-commits mailing list