[Seaside] Porting to ST/X

Avi Bryant avi@beta4.com
Thu, 7 Mar 2002 00:18:25 -0800 (PST)


On Wed, 6 Mar 2002, Avi Bryant wrote:

> > Would someone be able to put together
> > some simple test cases for me around Continuation so that I can see
> > what it is I am trying to achieve.
>
> I'll think about that and see if I can post something for you.

Ok, so here are some simple tests:

"1. This gets across the basic idea of callCC without getting hairy.  It
can be implemented as

BlockContext>>callCC
  ^ self value: [:v | ^ v]"

|x|
x := [:cc | cc value: true] callCC.
x ifTrue: [Transcript show: 'success']

"2. This requires some stack trickery - using the naive implementation
above you'll run into problems with returning from the same context
twice."

|x continuation|
x := [:cc | continuation := cc. false] callCC.
x ifTrue: [Transcript show: 'success']
  ifFalse: [continuation value: true].

"3. This tests the particular form of continuations Seaside uses, where
the stack is copied each time, so that each invocation has its own set of
temps"

|i continuation|
i := 0.
i := i + ([:cc | continuation := cc. 1] callCC).
i = 2 ifTrue: [Transcript show: 'success']
      ifFalse:
        [i = 3 ifTrue: [Transcript show: 'failure'].
               ifFalse: [continuation value: 2]].

------

Hope this helps.  I should point out that I did spend some time hacking
around in ST/X trying to get this stuff working, but to no avail...
hopefully you'll have better luck.

Cheers,
Avi