Ruby and Python

Hrvoje Niksic hniksic at arsdigita.com
Mon Nov 20 08:52:19 EST 2000


"Alex Martelli" <aleaxit at yahoo.com> writes:

> """
> In Scheme, as in most dialects of Lisp, functions are first-class. This
> means that they are values, just like any other data type--they may be
> passed as arguments to functions  and returned as values of functions.
> """

The last part is what distinsguishes "first-class" from
"second-class".  In C, for instance, functions might be called
second-class objects because you can pass them to functions, but you
cannot meaningfully return new ones from functions.

The whole story about the enclosing environment is a red herring
anyway, because it relies on side-effects.  When using proper
*functions* in Python, they are always first-class objects, *and* you
need no namespace games for them to work.

If you're using side-effects, then it's up to the language whether
they will be implicit (inferred from the enclosing lexical
environment) or explicit (the "self" parameter of a bound method or
optional parameters in function definition).



More information about the Python-list mailing list