Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Feb 19 00:00:51 CET 2010


On Thu, 18 Feb 2010 08:15:46 -0800, Steve Howell wrote:

> Just to be clear, I'm not saying it's unforgivable to occasionally ship
> software with bugs.  It happens.

"Occasionally"? Oh, if only.

I would say that there probably isn't a non-trivial application in the 
world that is entirely bug-free. If you're shipping something more 
complex than the proverbial "Hello World", chances are high that there 
will be bugs, and the more complex the app, the more bugs are likely.


> Compressing Javascript is sometimes necessary, but I believe that often
> mangles named functions too.

It doesn't mangle the function, it mangles reporting of line numbers. But 
if you know the name of the function, it is much easier to recover from 
that loss of information.

 
> To the the extent that your customer is running old software and cannot
> always coherently describe tracebacks over a telephone, that problem can
> be solved in the software itself, assuming an Internet connection.  The
> software can capture the traceback and report back to a server with the
> version number.

I don't understand why you repeatedly mention "old software". It is 
irrelevant: the software is either supported, or not supported. If it's 
not supported, you don't care about the bugs. If it is supported, then it 
doesn't matter whether it is version 2.2 or 2.3 or the bleeding edge 2.4-
pre-alpha straight out of subversion, you still have to go through the 
same process of finding the bug, solving it, then rolling the fix out to 
all supported versions where the bug applies.

That's not to say that the version number isn't useful information to 
have, because it can be, but distinguishing between old versions and the 
current version isn't a useful distinction. In a sense, there are no old 
versions, there are merely multiple supported current versions.

> So, much of the argument against anonymous functions presented so far is
> really orthogonal to whether functions are named or not.

Not so. The point is that anonymous functions lack useful information, 
namely the function name. Because line numbers can be unreliable or even 
missing completely, and even when reliable many people have a mental 
blind-spot for them (I know I do, and I'm gratified to see I'm not the 
only one), lacking a good name for the function is a handicap. Not 
necessarily an insurmountable one, but anonymous functions are more 
troublesome than named functions.

You wouldn't name your functions:

f01, f02, f03, f04, ... f99

(say), unless you were trying to deliberately obfuscate your code. 
Anonymous functions are even more obfuscated than that. You can get away 
with it so long as you're only dealing with a few, in well-defined 
placed, but you wouldn't want to use them all over the place.

-- 
Steven



More information about the Python-list mailing list