Returning none

Michael P. Reilly arcege at shore.net
Fri Sep 3 11:28:01 EDT 1999


Gordon McMillan <gmcm at hypernet.com> wrote:
: C. Laurence Gonsalves wrote:

:> Perhaps your programming style is different than mine. I know I've
:> frequently run into situations where I've forgotten to actually
:> return the result I calculated. Apparently others have as well. I'm
:> also sure there is a lot of code that ignores return values. There's
:> a way to add checking for this as well...

: I won't pretend I've never been bitten by this, or that it's always 
: easy to track down. But when I learned Pascal (my 4th language, I 
: think), I found the distinction between functions and procedures to 
: be very tiresome. A dozen years later when I had to write PL/SQL, I 
: had the same reaction. It means that for almost every call I make, I 
: have to remember or look up whether it's a function or a procedure. 

: I guess I have more sympathy for the functional style, though I find 
: the no side-effects restriction extreme. So Python's liberal rules 
: (side effects allowed) and consistency (everything returns a result, 
: whether desired or meaningful) are, to me, just dandy.

: So put me firmly in the camp that favors a stronger PyLint (I just 
: recently got bit by a rarely used bare return in some released code).

Me too on the "this looks like a job for...".  Lint programs are made
for programmers who forget things (like forgetting this is Python and
not P***) - just about every programmer forgets something.  Changing
the language with no real gain is not the answer..  there's loss of
functionality by making functions act like procedures and raise
exceptions if they aren't.

One powerful, often used construct is treating callables as first
class: does the callable return a value? That doesn't matter, the
interface needs to be consistant to work properly, and currently it
does.  Do we now have new functions for apply, map, filter to handle
"procedures"?  (Are these now procedures?)  You then have to know ahead
of time if the callable is a function or a "procedure".  You can't mix
at a non-predetermined point, functions and "procedures".  This just
adds to the complexity of the language and implementations needlessly,
removing important functionality.

Change is good... if the change is for the good.

  -Arcege





More information about the Python-list mailing list