Ruby and Python
aleaxit at yahoo.com
Sun Nov 19 09:44:37 CET 2000
"graham" <graham73 at telocity.com> wrote in message
news:B63CA023.172F7%graham73 at telocity.com...
> > 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
But of course it IS an object, just like a function-object is one.
That is, by Python definition. If you're thinking 'class-instance'
when you say 'object', then neither ints not functions in Python
are 'objects' in THIS sense.
> 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
No! Absolutely no difference.
c = lambda x, y=a, z=b: x + y + z
You don't have to be any more explicit about where a and b
are 'coming from' (which environment or namespace) in the
definition of this object (which you're binding to c) than you
do in the definition of the object that YOU were binding.
> are not treated like other objects, and hence are not first class.
They're treated exactly like every other object, and thus
More information about the Python-list