[Python-ideas] Where-statement (Proposal for function expressions)
Mike Meyer
mwm-keyword-python.b4bdba at mired.org
Sat Jul 18 00:47:19 CEST 2009
On Fri, 17 Jul 2009 02:04:05 +0200
"Jan Kaliszewski" <zuo at chopin.edu.pl> wrote:
> 17-07-2009, 00:51 Mike Meyer <mwm-keyword-python.b4bdba at mired.org> wrote:
>
> > That they cause problems with your first attempt at
> > describing an implementation certainly isn't reason to disallow them
> > all by itself.
>
> But, it isn't a problem of implementation. I don't see any reasonable
> *semantics* of return or yield within where-block in proposed form.
> return/yield statements seem to be completely unnecessary in this context.
> (Of course, I don't say about return/yield statements within functions
> defined within where-block).
Seems obvious to me:
def foo(x):
bar = foundbar where:
if x is None:
return -1
foundbar = x * 2
return bar
The return will return -1 from foo if it's invoked; the assignment to
bar (and foundbar, for that matter) will never happen.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the Python-ideas
mailing list