Bug or feature?
Alexey Nezhdanov
snake at penza-gsm.ru
Fri Jan 16 09:44:33 EST 2004
Terry Reedy wrote:
> "Dennis Lee Bieber" <wlfraed at ix.netcom.com> wrote in message
> news:3dtid1-594.ln1 at beastie.ix.netcom.com...
>
>>Alexey Nezhdanov fed this fish to the penguins on Wednesday 14 January
>>2004 21:40 pm:
>>
>>
>>>Case 1 and case 2 prints out different calues (1 and 2 respectively).
>>>Do not know - if this is a bug or feature of python.
>>>
>>
>> It's a problem with using what I would consider a side effect...
>
> And
>
>>not understanding that "variables" are not memory addresses.
>
>
> In particular, the problem with both modifying in place (the side effect)
> and returning a value. I see a little better Guido's reason for having
> list modification methods return None. While chaining is not too
> problematical, object returns would allow list expressions mixing implicit
> and overt effects with possible puzzles similar to the one presented in
> this thread.
>
> Terry J. Reedy
So since the word "problem" is so popular in this tred I have an another
question:
Does anybody agree that this is a python problem and not a programmer
problem?
Let me explain.
I DO know that this behaivoir of python is matches the DOCS and all
declared official language laws.
I DO know why it is happening and how to fix my program to solve the
problem (in fact I already knowed it when written my first post here).
I DO know that fixing on python level it will rise particular
incompartibility with previous versions of python.
BUT
I know the case where such python behaivoir causes hard-to-catch problems.
I do not know any case (anybody knows? please give example) where such
"feature" may be useful.
So I proposing to make a change into python and reverse the order of
calculations.
Just for sure:
=== Order used now ===
## a+=a.Sub(b)
1. evaluate value of 'a'
2. evaluate value of 'a.Sub(b)'
3. evaluate the sum
4. store the result into 'a'
=== Proposed order ===
## a+=a.Sub(b)
1. evaluate value of 'a.Sub(b)'
2. evaluate value of 'a'
3. evaluate the sum
4. store the result into 'a'
(same about -=, *=,... of course)
--
Respectfully
Alexey Nezhdanov
More information about the Python-list
mailing list