Origin of the term "first-class object"

Aahz aahz at pythoncraft.com
Mon Nov 24 12:33:40 EST 2003


In article <m8uub.235682$HS4.2034763 at attbi_s01>,
Rainer Deyke <rainerd at eldwood.com> wrote:
>Aahz wrote:
>>Rainer:
>>>
>>> l[x * 2 + f(y)] = f(l[x * 2 + f(y)])
>>>
>>> This statement contains an obvious redundancy that will make code
>>> maintenance difficult.  Python allows me to factor out some of the
>>> redundancy:
>>>
>>> index = x * 2 + f(y)
>>> l[index] = f(l[index])
>>>
>>> However, Python gives me no way to factor out the remaining
>>> redundancy.
>>
>> Sure it does: change the immutable to a mutable.
>
>Not good enough.  

Why not?  Note that you're playing what is IMO an unfair game where you
keep changing the goalposts.

>I'd rather write "l[x] = f(l[x])" with all of its redundancy than wrap
>every conceivable immutable object in a mutable wrapper.  Besides, I
>don't *want* 'f' to change an object (which may also be referenced
>elsewhere); I want it to change a binding.

Well, you're going to have to pay for what you want in some fashion;
Python's going to keep its default semantics, so you're going to need
*some* kind of wrapper.

>And, really, "l[x] = f(l[x])" isn't that big of a deal.  It's a bit of
>redundancy that I'd rather not have, but it's not bad enough that I
>feel the need to do anything about it.

<shrug>  It's not a redundancy unless you're using a particular skewed
way of looking at things.  If you're going to skew, you might as well
keep skewing until you're using a Pythonic mechanism.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Weinberg's Second Law: If builders built buildings the way programmers wrote 
programs, then the first woodpecker that came along would destroy civilization.




More information about the Python-list mailing list