在 Perl 中从 Moose 迁移到 Mouse - 鼠标不执行 BUILD
为了提高速度,我试图从 Moose 迁移到 Mouse,但遇到了一个严重错误。
我正在同一范围内构建两个对象:
sub scope {
my $foo = Foo->new();
my $bar = Bar->new();
}
Foo 的 BUILD 方法正在触发,但 Bar 的 BUILD 方法没有触发。 有任何想法吗? Foo 和 Bar 都继承自 Baz,而 Baz 又继承自 Mouse::Object。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您并没有真正为任何人提供足够的上下文来调试它。
另外,我担心你的评论从 Moose 迁移到 Mouse“为了速度”而没有更好的。 有几个软件包的速度基准比 Mouse 或 Moose 更快。 对您的应用程序进行分析可能会显示您将 99% 的时间花费在元类编译、访问器访问和对象创建上……此时移植到 Mouse 可能是合理的。 事实可能是,您 99% 的时间都花在业务逻辑上,此时移植到 Mouse 对您没有任何帮助。
鼠标非常出色,并且有几个特定的用例。 当我知道我将在 Moose 传统上不擅长的环境(CGI)中运行时,我就在生产中使用了它。 然而,Mouse 并不是(正如有些人声称的那样)Moose + FAST ...Mouse 更像是 Moose - Class::MOP(以及所有在 MOP 级别标准化 Perl 的技巧)。
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).