I think I may have found a way to eliminate the need for the 'codef' keyword. I realised that although it's important to prevent making a regular call to a cofunction, there's no need to prevent making a cocall to an ordinary function. In that case, it can just be treated like a normal call. So I suggest the following changes: 1. The presence of 'cocall' inside a function causes it to be a cofunction. There is no 'codef' keyword. 2. The 'cocall' construct checks whether the function supports cocalls, and if so, proceeds as previously specified. Otherwise, it calls the function normally and returns the result. (To allow for objects such as bound methods to wrap things which could be cofunctions or not, the __cocall__ method will be permitted to return NotImplemented as a way of signalling that cocalls are not supported.) Does this scheme sound any better? -- Greg
On Tue, Aug 10, 2010 at 10:45 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
2. The 'cocall' construct checks whether the function supports cocalls, and if so, proceeds as previously specified. Otherwise, it calls the function normally and returns the result.
Does this scheme sound any better?
Well, considering: On Sun, Aug 1, 2010 at 4:52 AM, <ghazel@gmail.com> wrote:
It seems like calling a normal function using this special calling mechanism could treat them like a cofunction which produced zero iterations and a single return value.
I would say yes. :) -Greg
participants (2)
-
ghazel@gmail.com
-
Greg Ewing