在 Perl 中从 Moose 迁移到 Mouse - 鼠标不执行 BUILD

发布于 2024-07-14 02:04:43 字数 277 浏览 4 评论 0原文

为了提高速度,我试图从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亢潮 2024-07-21 02:04:43

您并没有真正为任何人提供足够的上下文来调试它。

另外,我担心你的评论从 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文