I'm wrong or Will we fix the ducks limp?
BartC
bc at freeuk.com
Thu Jun 9 08:25:28 EDT 2016
On 09/06/2016 12:08, Antoon Pardon wrote:
> Op 09-06-16 om 12:48 schreef BartC:
>>
>> What does it matter?
>>
>> If swap() can be implemented via such a function, then it means that
>> the language has such capability, which can be useful in different
>> scenarios.
>>
>> If it can't, then the language hasn't.
>>
>> Python doesn't have it so it can't implement swap like that.
>>
>> There's no need to bring references into it at all.
>
> Whether a language can implement a swap procedure like that is
> not the same question as whether the language variables are
> references or not.
Now /you're/ turning it around.
I'm not interested in the internal references that Python currently
uses. (I've called them /object references/.)
I'm talking about a different kind of reference, possible /name
references/, they would make possible new things ....
> Since the topic was whether or not python has reference variables,
> is seems there is no need to bring this swap procedure into it at all,
> instead of turning it around and pretending it was about the
> swap procedure.
... such as implementing a function that can exchange the values of its
caller's two arguments.
In bytecode, Python might need to swap variables using:
load a
load b
store a
store b
(which can get inefficient if swapping a[i+j-1] and b[j-i+1]). A name
reference would allow:
loadref a
loadref b
swap
--
Bartc
More information about the Python-list
mailing list