By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,743 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,743 IT Pros & Developers. It's quick & easy.

Info on continuations?

P: n/a

Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.

Saw a few URLs which had some info, some of which I understood. But
like I said, personal viewpoints are good to have.

Thanks
Vasudev
-------------------------------------------------------------------------------------------------------------------------
Software consulting and training
http://www.dancingbison.com
PDF conversion toolkit: http://sourceforge.net/projects/xtopdf (stable
version 1.0, supports
plain text and DBF conversions to PDF)
-------------------------------------------------------------------------------------------------------------------------

Aug 8 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

vasudevram wrote:
Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.

Saw a few URLs which had some info, some of which I understood. But
like I said, personal viewpoints are good to have.

Thanks
Vasudev
Could you be a little more specific on what you're looking for?
Continuations are a big can of worms.

In general, some of the historical uses of continuations are better
represented as classes in python. Generators provide some limited
functionality as well, and will be able to send info both ways in
python 2.5 to enable limited co-routines. Stackless python allows you
to *really* suspend the stack at a given time and do a bunch of crazy
stuff, but doesn't currently support 'full continuations'.

Aug 8 '06 #2

P: n/a

ol*****@verizon.net wrote:
vasudevram wrote:
Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.
Could you be a little more specific on what you're looking for?
Continuations are a big can of worms.
Thanks for the reply. Can't really be more specific, since I don't know
enough. The question and the interest was exploratory in nature - as
part of wanting to learn more about some dynamic / advanced features of
Python. Will Google more and read the docs ...

Vasudev

Aug 8 '06 #3

P: n/a
vasudevram wrote:
Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.
Python does not have (full) continuations. If you want to understand
continuations,
you need a language that supports them. For instance this is a recent
reference for continuations in Scheme:
http://www-128.ibm.com/developerwork...w02FlowControl

Ruby should have support for continuations too, but I am quite ignorant
about the Ruby literature.

Michele Simionato

Aug 8 '06 #4

P: n/a

Michele Simionato wrote:
vasudevram wrote:
Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.
Thanks to all who replied.

Vasudev

Aug 8 '06 #5

P: n/a
vasudevram wrote:
>
Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.

Saw a few URLs which had some info, some of which I understood. But
like I said, personal viewpoints are good to have.
Python doesn't really support continuations. Generators (and co-routines in
general) have similar properties to continuations, however they're not
continuations. Closures are also sometimes considered cousins to
continuations, and python's support for those is pretty good IMO. (again
however, closures are not continuations).

Since it looks like you're also looking for what continuations are, I think
the following is the simplest way of explaining them. If you've ever
programmed in BASIC, *in a way* if you think of methods/functions as a
named GOSUB, then continuation (in a way) are a way of giving a name to a
goto (it's more subtle than that though since a continuation os often
defined to "remember" state in a similar way to a closure). Like a function
you can pass them round as objects. Like a generator/closure they remember
the state they were in.

*Personally* , I think python NOT supporting full continuations is a GOOD
thing, since full continuations, whilst powerful, are also a great source
of confusion for people. (That said, I have a usecase I'd find them useful
for - I think they'd be useful for plugin architectures - but IMO that
doesn't outweigh the risk of code obfuscation :-)

One particular usecase that people seem to like continuations for,
specifically how they're used in seaside, is actually a subset of
functionality that python *can* support (to a large extent).

Essentially the idea is to be able to take a web application and make it
look linear. CherryFlow allows you for example to write this:

@expose
@flow
def example_flow():
yield view.first_page()
if request.args["choice"] == "a":
yield view.choice_a_page()
else:
yield view.choice_b_page()
yield view.last_page()

(example from: http://tinyurl.com/qzpqu )

This causes the user's browser to show a page where they have a choice of
"a" or "b". Depending on what they choose, they then either are presented
with choice_a_page or choice_b_page. Finally, no matter which option they
chose, you are presented with the last page.

Something similar can be done using Kamaelia, though at present only the
mechanism exists there, without any sugar (http://tinyurl.com/n3bh7 -
specifically websiteSessionExampleComponent). The reason I mention it is to
say that it's relatively simple to do using python :-)

I have to stress though, this usage of continuations in Seaside, as
emulate-able in python is a subset of the full power of continuations,
which isn't available in python at present. (Though it's possible hacking
greenlets could result in something). (In fact the way seaside uses them as
far as I can tell is more to implement co-routine like behaviour than
anything else (!))

Anyway, hope that's interesting/useful - looking at your other comments,
you're just looking for information and usecases at the moment :-)

Regards,
Michael.

Aug 8 '06 #6

P: n/a

Michael wrote:
vasudevram wrote:

Hi,

I am Googling and will do more, found some stuff, but interested to get
viewpoints of list members on:

Continuations in Python.

Saw a few URLs which had some info, some of which I understood. But
like I said, personal viewpoints are good to have.

Python doesn't really support continuations. Generators (and co-routines in
general) have similar properties to continuations, however they're not
continuations. Closures are also sometimes considered cousins to
continuations, and python's support for those is pretty good IMO. (again
however, closures are not continuations).

Since it looks like you're also looking for what continuations are, I think
the following is the simplest way of explaining them. If you've ever
programmed in BASIC, *in a way* if you think of methods/functions as a
named GOSUB, then continuation (in a way) are a way of giving a name to a
goto (it's more subtle than that though since a continuation os often
defined to "remember" state in a similar way to a closure). Like a function
you can pass them round as objects. Like a generator/closure they remember
the state they were in.

*Personally* , I think python NOT supporting full continuations is a GOOD
thing, since full continuations, whilst powerful, are also a great source
of confusion for people. (That said, I have a usecase I'd find them useful
for - I think they'd be useful for plugin architectures - but IMO that
doesn't outweigh the risk of code obfuscation :-)

One particular usecase that people seem to like continuations for,
specifically how they're used in seaside, is actually a subset of
functionality that python *can* support (to a large extent).

Essentially the idea is to be able to take a web application and make it
look linear. CherryFlow allows you for example to write this:

@expose
@flow
def example_flow():
yield view.first_page()
if request.args["choice"] == "a":
yield view.choice_a_page()
else:
yield view.choice_b_page()
yield view.last_page()

(example from: http://tinyurl.com/qzpqu )

This causes the user's browser to show a page where they have a choice of
"a" or "b". Depending on what they choose, they then either are presented
with choice_a_page or choice_b_page. Finally, no matter which option they
chose, you are presented with the last page.

Something similar can be done using Kamaelia, though at present only the
mechanism exists there, without any sugar (http://tinyurl.com/n3bh7 -
specifically websiteSessionExampleComponent). The reason I mention it is to
say that it's relatively simple to do using python :-)

I have to stress though, this usage of continuations in Seaside, as
emulate-able in python is a subset of the full power of continuations,
which isn't available in python at present. (Though it's possible hacking
greenlets could result in something). (In fact the way seaside uses them as
far as I can tell is more to implement co-routine like behaviour than
anything else (!))

Anyway, hope that's interesting/useful - looking at your other comments,
you're just looking for information and usecases at the moment :-)

Regards,
Michael.
Yes, that's quite right - only looking for info and use cases at
present - and thanks for the info, it was interesting and useful :-)
Need to check all the inputs out ...

Vasudev

Aug 9 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.