Are we hammering thumbtacks? [was: Re: x=(yield from) confusion]

On Fri, Apr 3, 2009 at 8:32 PM, Nick Coghlan <ncoghlan@gmail.com> wrote:
Yes, this explanation and example finally made that clear to me. But it also makes me wonder if we aren't using the wrong tool. It seems that you want the yields to pass opaquely through average_diff -- possibly without any actual value; just a go-ahead-and-suspend-me flag. Meanwhile, you do want some values to be shared between average_diff and average_cr. average_diff can send in some initial values when it creates/initializes average_cr, but there isn't any way to get information back without hijacking the stream of yields. The proposals below are more ambitious than the current PEP, but they still somehow feel less contorted by special cases: Option 1: Recognize that yield is serving two purposes, and find another way to spell go-ahead-and-suspend-me. It may be too late to do this cleanly. Option 2: Find another way for average_diff and average_cr to share information. Option 2a: Add anoher set of methods, similar to send, but specific to co-routines. This starts to look like the Actor that Bruce Eckel asked about a a while ago, and Kamaelia may have a good pattern. Option 2b: Let the caller and callee share a scope, similar to exec in locals. (Previous discussions talked about thunks or macros.) -jJ
participants (1)
-
Jim Jewett