[Python-ideas] Syntax: 'return: ...' expressions

Yawar Amin yawar.amin at gmail.com
Wed Jan 7 06:29:27 CET 2015

On 2015-01-06 23:43, Andrew Barnert wrote:
> [...]
> That's equivalent to arguing that function bodies don't need return,
> break, or continue, because you can theoretically write anything to
> fall off the end.

Not really; it's more like arguing that the particular proposed new
syntax doesn't need a return statement because it is defined to
automatically return its last expression (i.e., 'fall off the end'). All
other control structures and syntax keep their existing behaviour,
including functions.

And in any case, many languages don't have any concept of a return
statement; they _do_ actually return the last expression in their
function bodies.

> I'm assuming that the OP wanted something that works intuitively
> similar to other languages, the REPL, etc.--e.g., if the last
> statement executed is in the true block of an if/else, it doesn't
> matter that it's not textually the last statement.

Not exactly, I think ... I just wanted a way to 'wrap' statements inside
expressions. That would unify the two concepts in Python and make it
much more expressive.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150107/d6691a09/attachment-0001.sig>

More information about the Python-ideas mailing list