[Stackless] Continuations in Forth

Just van Rossum just at letterror.com
Tue Oct 31 19:36:39 CET 2000


At 2:57 PM +0100 31-10-2000, Dirk-Ulrich Heise wrote:
>Really? Aren't two different continuations supposed to be
>completely independant?

I wouldn't know what they're "supposed" to be...

>Or do you mean, that his happens
>as a consequence to Pythons semantics?

Erm, it's a consequence of two continuations that belong to the same frame
sharing much of the frame data, including the locals dict (& fast locals
array).

>So, if continuation
>one has a variable that refers to some object A and continuation
>two refers to it as well, and object A is mutable, it would
>appear changed in both continuations? That would be okay,
>as it is a direct consequence of Python semantics.

No it's the actual variable bindings that are shared.

Example:

import continuation

def foo():
	what = continuation.return_current()
	a = 1
	if what == "one":
		continuation.return_current()
		a = 2
	elif what == "two":
		continuation.return_current()
		print "current value of 'a':"
		print a

init = foo()
one = init("one")
two = init("two")
print "initial value of 'a':"
print one.locals['a']
print two.locals['a']
one()  # modifies a
two()


Just


_______________________________________________
Stackless mailing list
Stackless at starship.python.net
http://starship.python.net/mailman/listinfo/stackless



More information about the Stackless mailing list