Ruby and Python
Erno Kuusela
erno-news at erno.iki.fi
Sat Nov 18 21:47:48 EST 2000
>>>>> "graham" == graham <graham73 at telocity.com> writes:
graham> Actually it is a big deal. When you do
graham> c = a + b
graham> to construct the object c (say a and b are ints, although
graham> in this case c isn't an object, but that doesn't change me
(why do you say c isn't an object?)
graham> point), you don't have to say where you are getting a and
graham> b from (which environment or namespace or whatever you
graham> want to call it). But if I want to define a function I do
graham> have to be explicit about where I am getting objects used
graham> in the function definition from. So functions are not
graham> treated like other objects, and hence are not first class.
it is exactly the same. in the "c = a + b" example, variables are only
looked up in the local and global scopes, same as when you are
defining a function. if a or b are in some lexically enclosing scope,
it won't work.
lexical scoping would be cool, otoh it could serve to obfuscate
code... (although not as much as list comprehensions)
-- erno
More information about the Python-list
mailing list