Set::Scalar 宇宙如何工作?

发布于 2024-10-07 07:40:47 字数 81 浏览 0 评论 0原文

我创建了很多集合,并且我注意到它们都共享同一个宇宙。

我不明白宇宙是如何维持的。它是脚本中所有集合共享的一个宇宙(某个全局变量)吗?

I have created many sets and I noticed that all share the same universe.

I couldn't figure out how the universes is maintained. Is it one universe shared by all sets in the script (some global variable)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

╭ゆ眷念 2024-10-14 07:40:47

好吧,实际上它是 Set::Scalar::Universe:

my $UNIVERSE = __PACKAGE__->new;

sub universe {
    my $self = shift;

    return $UNIVERSE;
}

然后在 Set::Scalar 中你有:

$self->{ universe } = Set::Scalar::Universe->universe;

它只是获取一个副本该变量的值(在加载 Set::Scalar::Universe 时初始化。Set

::Scalar 文档顺便提到,不相交的 Universe 尚未实现。

Well, actually it's a lexical variable in Set::Scalar::Universe:

my $UNIVERSE = __PACKAGE__->new;

sub universe {
    my $self = shift;

    return $UNIVERSE;
}

Then in Set::Scalar you have:

$self->{ universe } = Set::Scalar::Universe->universe;

which simply fetches a copy of that one variable (which got initialized when Set::Scalar::Universe was loaded.

The Set::Scalar docs mention in passing that disjoint universes are not yet implemented.

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