使用 Seaside 延续

发布于 2024-07-07 18:43:42 字数 288 浏览 6 评论 0原文

如何在 Squeak 中获得 BlockClosure(我想使用 BlockClosure>>callCC)?

当我写 [#foo] 时,它是一个 BlockContext,这是怎么回事?

更新:我已经发现 BlockClosure 主要是新编译器的一个东西。

相反,我如何使用海边延续? 我遇到了问题,任何例子将不胜感激。

进一步更新:这样做的目的不是使用seaside(至少不是直接使用),而是以比滚动我自己的状态跟踪迭代器更容易的方式编写遍历和其他类似的东西。

How do I get a BlockClosure in Squeak (I want to use BlockClosure>>callCC)?

When I write [#foo] that is a BlockContext, what's the deal?

Update: I have worked out that BlockClosure is a thing mainly of new compiler.

Instead how do I work with seaside Continuations? I'm having problems, and any examples would be appreciated.

Further update: The purpose of this is not to use seaside (at least not directly) but rather to write traversals and other such things in a way that is easier than rolling my own state-tracking iterators.

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

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

发布评论

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

评论(1

月朦胧 2024-07-14 18:43:43

通常,使用 Seaside,您根本不需要自己处理 Continuations。

您只需在组件中使用 #call:#answer: 即可。

如果除了编写 Seaside 应用程序之外,您还尝试使用 Continuation 执行其他操作,请查看 WAComponent>>call: 以获取使用示例。

或者试试这个。 打开成绩单窗口。 现在,在工作区中,一次选择所有这些代码并执行:

continuation := nil.
result := Continuation currentDo: [:cc |
   "store the continuation, cc, somewhere for later use"
   continuation := cc.
   1 ].

Transcript show: result.

您应该看到“脚本”窗口中显示 1。 现在,在工作区中,执行:

continuation value: 2

然后:

continuation value: 3

您应该会看到传递给 continuation 的每个值都显示在 Transcript 中,因为传递给 #value: 的每个值都会导致恢复延续的上下文,并且分配给结果的新值。

希望这有帮助...

Normally, with Seaside, you never have to deal with Continuations yourself at all.

You just use #call: and #answer: from within your components.

If you're trying to do something else with Continuation other than writing a Seaside application, take a look at WAComponent>>call: for an example of usage.

Or try this. Open a Transcript window. Now, in a Workspace, select all of this code at once and Do-it:

continuation := nil.
result := Continuation currentDo: [:cc |
   "store the continuation, cc, somewhere for later use"
   continuation := cc.
   1 ].

Transcript show: result.

You should see 1 displayed in the Transcript window. Now, in the workspace, do:

continuation value: 2

and then:

continuation value: 3

You should see each value you pass to continuation displayed in the Transcript because each value you pass to #value: causes the context of the continuation to be restored and the new value assigned to result.

Hopefully that helps...

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