Ruby and Python

graham graham73 at
Sun Nov 19 03:07:47 CET 2000

Alex Martelli
> "graham" <graham73 at> wrote in message
>> But functions in Python aren't first class either. The most obvious
>> evidence of this is having to write manual closures.
> What does this have to do with functions' "first-classness"?  Python
> doesn't do nesting of lexical scopes -- which is a completely separate
> issue from that. 
> restrictions apply to the ways you can handle them.
> ...
> You may dislike having to be explicit about the details
> of the new function object -- 'use the code of local
> function add, use the current variable look-up settings
> as the "global" namespace' -- and wish new.function
> defaulted them for you, but it doesn't.  Big deal.

Actually it is a big deal. When you do

    c = a + b

to construct the object c (say a and b are ints, although in this
case c isn't an object, but that doesn't change me point), you don't
have to say where you are getting a and b from (which environment or
namespace or whatever you want to call it). But if I want to
define a function I do have to be explicit about where I am
getting objects used in the function definition from. So functions
are not treated like other objects, and hence are not first class.


More information about the Python-list mailing list