views:

417

answers:

1

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.

+7  A: 

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...

Julian