[squeak-dev] Scheme continuations vs Squeak continuations

Lukas Renggli renggli at gmail.com
Fri Jan 30 20:26:14 UTC 2009

> do you have any pointer about an alternate implementation which would
> capture inst vars as well ?

What about something like this?

Continuation>>initializeFromContext: aContext
	| valueStream context |
	valueStream := WriteStream on: (Array new: 20).
	context := aContext.
	[context notNil] whileTrue:
		[valueStream nextPut: context.
		1 to: context class instSize do: [:i | valueStream nextPut: (context
instVarAt: i)].
		1 to: context localSize do: [:i | valueStream nextPut: (context localAt: i)].
		valueStream nextPut: context receiver snapshotCopy. " <-- add this line "
		context := context sender].
	values := valueStream contents

	| valueStream context |
	valueStream := values readStream.
	[valueStream atEnd] whileFalse:
		[context := valueStream next.
		1 to: context class instSize do: [:i | context instVarAt: i put:
valueStream next].
		1 to: context localSize do: [:i | context localAt: i put: valueStream next].
		context receiver restoreFromSnapshot: valueStream next " <-- add this line " ]

Note that this does not solve the problem of the workspace variable
though. Workspace bindings are like global data and a continuation
cannot know what data outside its context you want to backtrack.
That's why there is a registration mechanism for objects in Seaside.


> Stef

Lukas Renggli

More information about the Squeak-dev mailing list