Re: [Python-ideas] A Continuations Compromise in Python

So you think a tail-call decorator approach would work, so long as the programmer enforces themselves that it is a tail call? This seems like a good compromise, if there is an implementation in the cookbook that does this sort of simple optimization. What might be a good approach is to watch how popular that sort of decorator is, and if it turns out to be more popular than is expected, perhaps putting it in the language would sound like a better idea. I'd rather the trampoline that implements tail calls be written in C than in Python, if it is heavily used.
Sorry, that was a sneaky trick question. I just wanted to make sure we're all on the same page that recursion *CAN* be a good way to write some things, even clearer than loops. The problem is that there are a whole host of things, like the graph traversal Jacob has pointed out, that can't work with such a low stack limit. I just find it annoying that the theoretically 'correct' and admittedly 'elegant' solution to a few pretty standard graph problems can't be expressed in Python because we hit the stack. (I'm excluding those that Jacob makes note can't use tail calls anyway) I also pointed out the continuation-passing-style web server, the actor model and messages as well as the generic trampoline replacement as all use cases. None of these are all that wide-spread, but I guess my point is that if there were a language feature that could help in all of these areas, that must count for something. There is no one 'killer' use case, but there's a good half dozen or so we've pointed out. Surely that puts the proposal on the same footing, at least, as co-routines. I also don't want to discount the performance benefit. I know I said above, my main thrust is towards allowing 'correct' implementations of algorithms to run in Python without hitting the stack limit, but it is a completely valid sub-issue if performance can noticeably increase, as Arnauld just linked to and I'll be reading here in a moment. Some have also mentioned that they're not fans of the actual keyword use. I wanted to try and split those two debates apart, whether or not it is warranted, which I believe it is, and how it should be implemented. I had another proposal on the actual keyword front, "return from", which looks like it would kind of provide some symmetry to the 'return' and 'yield' constructs and also reads pretty intuitively, in my opinion. Thanks everyone for your input so far. -JG

Le Tue, 5 May 2009 07:29:22 -0500, John Graham <john.a.graham@gmail.com> s'exprima ainsi:
Sounds good imo. return --> the process does not go farther in the curent func from --> there a detour Continue (as used in loops) implies instead starting again. Denis ------ la vita e estrany

On 5/5/09, spir <denis.spir@free.fr> wrote:
Le Tue, 5 May 2009 07:29:22 -0500, John Graham <john.a.graham@gmail.com> s'exprima ainsi:
Starting with a clean slate, I would agree. In practice, "return from" may already have too strong an association with its use in lisp-like languages. The real meaning here is closer to GOTO; I would expect a "return from" to pop several layers from the stack (rather that simply replacing the current one). -jJ

On Tue, May 5, 2009 at 10:31 PM, Jim Jewett <jimjjewett@gmail.com> wrote:
Embrace, extend, destroy. It's not enough we take tail calls from the schemers, we'll teach a new generation of kids to think Lisp is even weirder than it is by reusing their terms! :)

<sarcasm> Perhaps we should implement "come from" and "go to" while we're at it. Oh, let's not leave out "alter" (for those of you old enough to have used COBOL) as well! </sarcasm> On Tue, May 5, 2009 at 11:31 PM, Jim Jewett <jimjjewett@gmail.com> wrote:
-- Gerald Britton

Le Tue, 5 May 2009 07:29:22 -0500, John Graham <john.a.graham@gmail.com> s'exprima ainsi:
Sounds good imo. return --> the process does not go farther in the curent func from --> there a detour Continue (as used in loops) implies instead starting again. Denis ------ la vita e estrany

On 5/5/09, spir <denis.spir@free.fr> wrote:
Le Tue, 5 May 2009 07:29:22 -0500, John Graham <john.a.graham@gmail.com> s'exprima ainsi:
Starting with a clean slate, I would agree. In practice, "return from" may already have too strong an association with its use in lisp-like languages. The real meaning here is closer to GOTO; I would expect a "return from" to pop several layers from the stack (rather that simply replacing the current one). -jJ

On Tue, May 5, 2009 at 10:31 PM, Jim Jewett <jimjjewett@gmail.com> wrote:
Embrace, extend, destroy. It's not enough we take tail calls from the schemers, we'll teach a new generation of kids to think Lisp is even weirder than it is by reusing their terms! :)

<sarcasm> Perhaps we should implement "come from" and "go to" while we're at it. Oh, let's not leave out "alter" (for those of you old enough to have used COBOL) as well! </sarcasm> On Tue, May 5, 2009 at 11:31 PM, Jim Jewett <jimjjewett@gmail.com> wrote:
-- Gerald Britton
participants (4)
-
Gerald Britton
-
Jim Jewett
-
John Graham
-
spir