On May 12, 3:56 pm, Pascal Chambon chambon.pas...@wanadoo.fr wrote:
Well, since adding new keywords or operators is very sensitive, and the existing ones are rather exhausted, it won't be handy to propose a new syntax...
One last idea I might have : what about something like
- def myfunc(a, b, c = yield ):
I'm not expert in english, but I'd say the following "equivalents" of yield (dixit WordWeb) are in a rather good semantic area : *Be the cause or source of *Give or supply *Cause to happen or be responsible for *Bring in
Of course the behaviour of this yield is not so close from the one we know, but there is no interpretation conflict for the parser, and we might quickly get used to it :
- yield in default argument => reevaluate the expression each time
- yield in function body => return value and prepare to receive one
How do you people feel about this ? Regards, Pascal
I'm not a fan. If you thought not reevaluating function expressions was confusing for newbies, wait until you see what making up a new kind of yield will do for them.
Why not just push for some decorators that do this to be included in stdlib? I see the utility, but not the point of adding extra syntax.
... def f(x=a**2+2b+c): ... return x ...
a = 1 b = 2 c = 3 f()
This seems much more intuitive and useful to me than adding new meanings to yield.