Why don't people like lisp?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Oct 24 16:23:54 EDT 2003


On Fri, 24 Oct 2003 20:00:23 +0000, Rainer Deyke wrote:

> I DON'T want to manually close files.  I DON'T want to deal with the
> limitations of with-open-file.  And, here's the important bit, I DON'T WANT
> TO COMBINE OR CHOOSE BETWEEN THESE TWO METHODS, BOTH OF WHICH ARE FLAWED.
> 
> What I want to open a file and have it close automatically when I am done
> with it.  I can do that in C++.  Why can't I do it in Python?

In C++ you must choose between a local variable for the stream (which is
equivalent to with-open-file) or dynamically allocated object (which is
equivalent to open & close, where close is spelled delete).

You can't say that you want the C++ way and you don't want explicit open &
close and with-open-file, because they are equivalent! They differ only in
syntax details, but the style of usage and limitations are the same.

The only Python's problem is that there is no nice way to pass an
anonymous function to with-open-file, and try:finally: doesn't look so
nice either. I'm not defending Python's lack of large anonymous functions
but the interface of open, close & with-open-file in general, irrespective
of the programming language.

In particular you shouldn't wish for GC to find unused files because it's
impossible without sacrificing other GC properties. No languages does that
except misused CPython (you shouldn't rely on that).

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/





More information about the Python-list mailing list