I'm wrong or Will we fix the ducks limp?

Antoon Pardon antoon.pardon at rece.vub.ac.be
Wed Jun 8 03:53:57 EDT 2016


Op 07-06-16 om 17:33 schreef Random832:
> On Tue, Jun 7, 2016, at 08:32, Antoon Pardon wrote:
>>> Here's a thought experiment for you. Suppose in Python 3.6, Guido announces 
>>> that Python will support a form of high-level pointer (not the scary, dangerous 
>>> low-level pointer of C) called "reference". There will be a dereference 
>>> operator, ^, and a "reference to" operator, @. We'll be able to treat 
>>> references as first-class values:
>> That makes very little sense in python.  
> Why not? If you prefer, think of it something like:

The fact that you can make it somehow work, doesn't mean it
makes much sense. If you don't like the limitation of the
assignment semantics in python, it seems more interresting
to change that, than to work around what we have now.

Python could go the simula route, which has two kinds of
assignment. One with the python semantics and one with C
semantics.

Let as use := for the C sematics assignment and <- for the
python sematics assignment. We could then do something like
the following.

ls := [5, 8, 13, 21]
a <- ls[2]
a := 34
print ls  # [5, 8, 34, 21]

Now it may very well be possible to achieve the same results
with what you have in mind, but in my mind it makes not much
sense in trying to achieve the semantics of a copy assignment
by building extra indirection on top of reference assignments.

-- 
Antoon Pardon




More information about the Python-list mailing list