From: Guillermo Roditi Date: Wed, 7 Jan 2009 21:06:23 +0000 (+0000) Subject: added doc bit about anon subrefs in the symbol table X-Git-Tag: 5.8000_05~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=04a48104b87288a52abbaee32bfd7396925fb5d9 added doc bit about anon subrefs in the symbol table --- diff --git a/lib/Catalyst/Upgrading.pod b/lib/Catalyst/Upgrading.pod index 781b821..4c8a28d 100644 --- a/lib/Catalyst/Upgrading.pod +++ b/lib/Catalyst/Upgrading.pod @@ -19,6 +19,28 @@ your Class' @ISA will not linearise with C3. 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 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 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