[Seaside] continuations and other mythical seaside things.
Julian Fitzell
seaside@lists.squeakfoundation.org
Sat, 30 Nov 2002 18:30:51 -0800
Derek Brans wrote:
> I am working on bringing the calendar application up to Seaside
> standards and I have some questions.
>
> Could you explain how continuations work?
> I understand that they store the state of execution of program control
> at a particular point in the program's execution, but how is this achieved?
Hmm.. I'll leave that one for Avi. I know how they work in general but
I've never looked into the details of implementation in Squeak.
> Does CC stand for continuation, as in callCC?
CC stands for current continuation
> Take a simple example, like WAContainer>>call. What does that do? What
> is a container?
A container is something that holds a component but allows it to be
swapped out. You can use #call: on the container to replace its
contents with a new component (until that component issues a call to
#answer or #answer:).
#call: works by calling WAComponent>>withContinuationDo:
This is implemented like so:
withContinuationDo: aBlock
^ [:cc | continuation _ cc. aBlock value] callCC.
the callCC method passes the current continuation into the block and
executes it. The block stores the continuation in the component's
continuation instvar and then executes the block.
Now anywhere in that block (any number of method calls deep), you could
make a call to #answer: which looks like:
answer: anObject
continuation ifNotNil: [continuation value: anObject]
The call to #value: on the continuation restores the state, program
counter, etc as appropriate so you can return from the original call to
#withContinuationDo:
Hopefully if you understand the general concept of continuations that
makes sense... but it's really quite hard to explain, particularly over
email.
> Also, if someone wanted to start putting short class comments into these
> classes, (it really woudn't take that long), how would they do it? I
> guess they'd need to have checkin privileges on SF?
>
No, you could send patches against the code on SF. Seaside 1 had class
comments before its first release but the code kept changing so much
that it kept getting out of date. We eventually had to just remove it
since inaccurate docs are worse than having none. So beware, we're not
likely to want to go that route until we're sure everything is stable or
you have some level of commitment to maintaining the comments on a
regular basis.
Julian
--
julian@beta4.com
Beta4 Productions (http://www.beta4.com)