Migrating from Moose to Mouse in Perl - Mouse not executing BUILD

烈酒焚心 提交于 2019-12-24 21:42:35

问题


I'm trying to migrate from Moose to Mouse in the interests of speed but have encountered a showstopper error.

I'm building two objects in the same scope:

sub scope {

   my $foo = Foo->new();
   my $bar = Bar->new();

}

The BUILD method of Foo is firing but the BUILD method of Bar is not. Any ideas? Both Foo and Bar inherit from Baz which inherits from Mouse::Object.


回答1:


You're not really providing enough context for anybody to debug this.

Also I'm worried about your comment migrating from Moose to Mouse "in the interests of speed" without having a better. There are several packages out there that benchmark faster than either Mouse or Moose for speed. Profiling your application may show that you spend 99% of your time in metaclass compliation, accessor access, and object creation ... at which point porting to Mouse might be justified. It may turn out that you spend 99% of your time in business logic at which point porting to Mouse won't do anything for you.

Mouse is excellent, and has several specific use cases. I've used it in production when I knew I'd be running in an environment that Moose is traditionally poor at (CGI). However Mouse is not (as some people seem to claim) Moose + FAST ... Mouse is more Moose - Class::MOP (and all the hacks that have gone into normalizing Perl at the MOP level).



来源:https://stackoverflow.com/questions/591767/migrating-from-moose-to-mouse-in-perl-mouse-not-executing-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!