why cannot assign to function call
steve at holdenweb.com
Mon Jan 5 19:31:48 CET 2009
Steven D'Aprano wrote:
> On Sun, 04 Jan 2009 20:03:11 -0600, Derek Martin wrote:
[...]>>>> And for that matter, it's pretty unintuitive generally.
>>> Names and objects are quite "natural" IMHO. There are many real world
>>> objects which we attach one or more names to, or refer to in sequences
>>> like "please give me the third book on that shelve" (``shelve``).
>> Indeed, but the way we assign names to them does not behave as it does
>> in Python.
> It doesn't?
> Oh my, you're going to be confused in a few weeks when The President of
> the USA ceases to be George W Bush and becomes Barack Obama. Same name
> (or rather, title), different object (person).
No, he will doubtless describe the White House as a President variable
whose value has been overwritten. There are many fine jokes to be made
about the need to garbage-collect President Bush ...
>> Nor does Python's assignment work like it does in algebra,
> Nor does any programming language, with the possible exception of
> computer algebra systems.
I'm still waiting for an explanation of where assignment comes into
algebra in the first place.
>> Those interpretations came first, because, much as in the
>> evolution of any other science, that was the model which was most
>> intuitive or easily explained.
> No no no no. That was the model that was most easily implemented!
Agreed. In those days the von Neumann architecture was a shiny new
thing, and it was even a while before people thought of using computers
for symbolic rather than numeric operations (which is IMHO what makes
them so interesting).
> Before the named bins model of assignment was pure machine code, where
> you didn't have bins at all, just bits, and there was no distinction
> between code and data. And before that was *wires* -- early programmers
> literally had to plug and unplug wires to change the state of the
> computer. And before that were purely mechanical devices, such as the
> Enigma Machine, old calculators, and the grand-daddy of them all, Charles
> Babbage's difference engine and it's precursors.
Aah, the old Univac 1004. Sorry, I'm rambling.
>> But you need not take my word for it. Simply read the archives and see
>> for yourself how much confusion this has caused on this list. [Please
>> include the closely related behavior of parameter passing in your
> In my opinion, the cause of that confusion is nothing to do with Python's
> assignment model, and everything to do with the instance of some people
> to use named bins terminology when describing the Python model. If you
> keep the named bins terminology for describing the named bins model,
> you're fine; and if you keep the name/object terminology for describing
> languages with names/objects, you're fine. You only run into trouble when
> you mix them. That's when you get people confused because "Python is Call
> By Something, but it doesn't behave like Call By Something in language
> Foo I've used before".
This really does go to show that (some) people will argue about
anything, with the major intention of proving themselves right rather
than reaching a common understanding.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list