[Python-Dev] Using and binding relative names (was Re: PEP forBetter Control of Nested Lexical Scopes) (original) (raw)
Ron Adam rrr at ronadam.com
Mon Feb 27 02:43:49 CET 2006
- Previous message: [Python-Dev] Using and binding relative names (was Re: PEP forBetter Control of Nested Lexical Scopes)
- Next message: [Python-Dev] Using and binding relative names (was Re: PEP forBetter Control of Nested Lexical Scopes)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alex Martelli wrote:
I'm -1 on adding the intermediate (outer) scopes to functions. I'd even like to see closures gone completely, but there's probably a reason they are there. What I like about functions is they are fast, clean up behind themselves, and act exactly the same on consecutive calls. Except that the latter assertion is just untrue in Python -- we already have a bazilion ways to perform side effects, and, since there is no procedure/function distinction, side effects in functions are an extremely common thing. If you're truly keen on having the "exactly the same" property, you may want to look into functional languages, such as Haskell -- there, all data is immutable, so the property does hold (any indispensable side effects, e.g. I/O, are packed into 'monads' -- but that's another story).
True, I should have said mostly act the same when using them in a common and direct way. I know we can change all sorts of behaviors fairly easily if we choose to.
Closures in Python are often extremely handy, as long as you use them much as you would in Haskell -- treating data as immutable (and in particular outer names as unrebindable). You'd think that functional programming fans wouldn't gripe so much about Python closures being meant for use like Haskell ones, hm?-) But, of course, they do want to have their closure and rebind names too...
So far everywhere I've seen closures used, a class would work. But maybe not as conveniently or as fast?
On the other side of the coin there are those who want to get rid of the "self" variable in class's also. Which would cause classes to look more like nested functions.
Haskel sounds interesting, maybe I'll try a bit of it sometime. But I like Python. ;-)
Ron
- Previous message: [Python-Dev] Using and binding relative names (was Re: PEP forBetter Control of Nested Lexical Scopes)
- Next message: [Python-Dev] Using and binding relative names (was Re: PEP forBetter Control of Nested Lexical Scopes)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]