Origin of the term "first-class object"

J

Jp Calderone

Aahz said:
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.

Up for a new operator?

l[index] ()= f

<1.5-wink>, Jp
 
A

Aahz

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.

Up for a new operator?

l[index] ()= f

"Boot to the head. <thump>"
 
G

Greg Ewing (using news.cis.dfn.de)

Jp said:
Up for a new operator?

l[index] ()= f

I like it! :)

I suppose you should be able to put extra args in, too, e.g.

l[index] (foo, 42)= f
 
B

Bengt Richter

Jp said:
Up for a new operator?

l[index] ()= f

I like it! :)
Me too ;-)
But I wonder if =()= wouldn't read more clearly, e.g.,

l[index] =()= f

and see below.
I suppose you should be able to put extra args in, too, e.g.

l[index] (foo, 42)= f
I presume that would imply that f had all optional args after the first.
What if you wanted to pass the update target in another position? E.g.,

l[index] =(foo, ??, 42)= f

where ?? is some kind of indicator for where to plug in the arg. I guess you
could use packing/unpacking if you had a tuple left side and several ??'s to match, e.g.,

a, l[index] =(foo, ??, 42, ??)= f

meaning

a, l[index] = f(foo, a, 42, l[index])

or course the targets could be simple as well

a, b =(foo, ??, ??, 42)= f

meaning

a, b = f(foo, a, b, 42)

Hm, I wonder about * for pack/unpack into arg tuple in this context

a, b =(foo, *??, 42)= f

maybe meaning

a, b = f(foo, (a,b), 42)

or did I get that backwards?

Sorry, can't help it ;-)

Regards,
Bengt Richter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,171
Messages
2,570,935
Members
47,472
Latest member
KarissaBor

Latest Threads

Top