On 15 November 2016 at 10:46, Paul Moore <p.f.mo...@gmail.com> wrote:
> If you're proposing a = a + b to introspect at runtime the type of a,
> and produce different bytecode depending on the answer, you're
> proposing a fundamental change to the runtime semantics of Python
> (such that the resulting language is arguably not even Python any
> more). That's not to say it can't be done, just that it's not in scope
> for "ideas about new features for Python" in any practical sense.

I thank you all again for informing me about assignment operator
and its further consequences. I read accurately and try to absorb
the information, still however I feel like I need just a little bit of more
understanding in this particular case.

So I can do better if we imagine, just imagine, such a scenario:

1.  += and friends are now not allowed for integers,
but all _add()_, _iadd()_ are still of course there,
it does not concern me.

2.  Somebody says: now I want to write something like:

  halfofanextremelylongvariable = halfofanextremelylongvariable + 1

3. I come up, scratch my head and say: Ok, now we can write that as:

  halfofanextremelylongvariable = self + 1

So, considering previous comments, there was an impression
that I wanted to shake the fundament of all Python world or something.
But is it necesserily so? So I don't know how the Python parser
works exactly, but why cannot the above roughly speaking "translated", e.g.:

  x = self + 1

would mean exactly the same that was before

  x += 1

and call __iadd()__ in turn.  Isn't it a very simple thing technically seen?
Since augmented assignment is always applied to exactly one argument
I believe (correct me if I am wrong), would not it be simple and
non-ambigios operation at parsing stage?
So in other words sequence " = self + " is same as sequence " += " was.

Another example, lets take a Numpy array  for example.
So it was also stated that += is vital for doing in-place sum.
Now I say, we write it in such way, having "A+=1" in mind:

  exec A + 1

since again, += can be only applied only on one operand, cannot I
just say that a sequence "exec {1} + {2}" is what sequence "{1}+={2}" was?

What semantics it will fundamentally break or so hard to implement?
I was actually trying to give similar ideas in previous comments,
but I was not precise in my ideas, so it came
to misunderstanding, or it can be that I'm still missing
something very important here.


Mikhail
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to