Why not allow empty code blocks?

Random832 random832 at fastmail.com
Sat Jul 30 23:51:31 EDT 2016


On Sat, Jul 30, 2016, at 22:17, Chris Angelico wrote:
> Yeah. The distinction means you have a fundamental API difference
> between the procedures (which don't return anything) and the functions
> (whose return values you mightn't care about).

Not really any more than between functions returning different types -
which python doesn't distinguish in general. That some languages may
spell it with a different keyword rather than a special type [such as
C's void] doesn't mean the fundamental API difference is of a different
kind.

> It means you can't
> upgrade something from "always returns None" to "returns the number of
> objects frobbed" without breaking compat. 

Well, that's something you can't do in general in statically typed
languages. (Once upon a time, C had a default return type of int, and
allowed functions returning it to fall off the end or have a "return;"
statement, but not anymore).

This is ultimately just the static typing argument in miniature,
confused by the fact that some languages declare them with a different
syntax from other functions.

> Conversely, if you decide
> that any function can be called "as a procedure" (this is what REXX
> does, for instance), then you've just merged the two types of callable
> and distinguished them only in usage.
> 
> Personally, I don't see any value to the distinction at all.
> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list