<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">Le 27/09/2018 à 12:48, Ken Hilton a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CADPFgpp4q8a0Hq=crAbisixGmQ6n7s27akvP4Fv2zBEOc3LcbQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff">Hi
Jasper,</div>
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff">This
seems like a great idea! It looks so much cleaner, too.</div>
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff"><br>
</div>
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff">Would
there be a dunder method handling this? Or since it's
explicitly just a syntax for "obj = obj.method()" is that not
necessary?</div>
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff">My
only qualm is that this might get PHP users confused; that's
really not an issue, though, since Python is not PHP.</div>
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff"><br>
</div>
<div class="gmail_default"
style="font-family:monospace,monospace;font-size:small;color:#0000ff">Anyway,
I fully support this idea.</div>
<br>
</div>
</blockquote>
What would the following evaluate to?<br>
a .= b + c(d)<br>
<br>
1: a = a.b + a.c(a.d) # everything is prepended an "a."<br>
it means we dn't have access to any external elements, making the
functionality only useful in a few cases<br>
<br>
2: a = a.b + a.c(d) # every first level element (if that means
something) is prepended an "a."<br>
We still lose some of the ability to access anything outside of `a`,
but a bit less than in #1. The effort to understand the line as
grown a bit, though.<br>
<br>
3: a = a.(b + c(d)) # everything is evaluated, and an "a." is
prepended to that result<br>
(the same way `a *= 2 + 3` is equivalent to `a *= 5`)<br>
I believe in most cases, this wouldn't mean anything to evaluate `b
+ c(d)` on their own, and expect a return that can be used as an
attribute of `a`.<br>
<br>
4: a = a.b + c(d) # "a." is prepended to the first element after
the `=`<br>
It is probably quite easy to read and understand, but it removes the
transitivity of the operators we have on the right, and is a bit
limiting.<br>
<br>
5: SyntaxError: Can only use the [whatever the name] augmented
operator with a single expression<br>
Why not, it's a bit limiting, but is clear enough to me.<br>
<br>
Maybe, a simpler thing to do for this problem would be to make
something like this:<br>
a = .b(5) + c(.d) + 3<br>
being the equivalent of<br>
a = a.b(5) + c(a.d) + 3<br>
<br>
I don't see any ambiguity anymore, it shortens the code a lot, and I
guess it wouldn't be hard for the compiler to recompose the line as
a first parsing step, and create the same AST with both syntaxes.<br>
</body>
</html>