使用 Seaside 延续
如何在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,使用 Seaside,您根本不需要自己处理 Continuations。
您只需在组件中使用
#call:
和#answer:
即可。如果除了编写 Seaside 应用程序之外,您还尝试使用
Continuation
执行其他操作,请查看WAComponent>>call:
以获取使用示例。或者试试这个。 打开成绩单窗口。 现在,在工作区中,一次选择所有这些代码并执行:
您应该看到“脚本”窗口中显示
1
。 现在,在工作区中,执行:然后:
您应该会看到传递给
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 atWAComponent>>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:
You should see
1
displayed in the Transcript window. Now, in the workspace, do:and then:
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 toresult
.Hopefully that helps...