On Tue, Dec 15, 2020 at 12:04:44PM +0300, Paul Sokolovsky wrote:
> I certainly agree. But the level at which I'm trying to discuss this
> matter is more "abstract interpretation"'ish. For example, "+" is a
> binary operator, you can't calculate "a + b + c" in one step. There're
> 2 "+", and thus 2 steps. And an intermediate result should be "stored
> somewhere". In different computation models that "somewhere" would be
> different, e.g. in the stack machine model, intermediate result would be
> stored in a location on the value stack, and in the register machine
> model - in ("temporary") register. But from abstract interpretation
> PoV, all those means of storage are equivalent: a named user variable,
> a stack location, a temporary variable. (They have differences beyond
> the "storage" aspect, sure.)
But they aren't equivalent: by definition, a named user variable has a
user-visible side-effect, while other forms of storage may not: in
high-level languages, stack locations, registers, and temporary
variables (in a non-user visible namespace) have no visible side-
effects.
So this is a critical distinction that you are not making:
- there are computations where such intermediate results are
visible to the user;
- and there are other computations where such intermediate
results are not visible to the user.
Those two classes are not equivalent, except approximately.
> So, let's try simple yes/no questions:
>
> Example 1:
>
> a + b + c vs a + (b + c)
>
> Question 1:
> Do you agree that there's a clear difference between left and right
> expression? Yes/no.
Are we talking about Python? Then yes, there is a clear difference.
In the first example, `a + b + c`, execution proceeds left to right: `a
+ b` first, then the result of that has c added on the right.
The second example changes the order of operations: `b + c` is computed
first, then a is added on the left.
> Example 2:
>
> a.b() vs (a.b)()
>
> Question 2:
> Do you agree that there's a *similar* difference here as in Example 1?
> Yes/no.
If we are still talking about Python, then no, there is no difference
between the two.
In the first example, the name "a" is looked up, then the attribute "b",
and then the result of that is called.
In the second example, the brackets have no effect: first the name "a"
is looked up, then the attribute "b", then the result of that is called.
In this case, the brackets do not change the order of operation. It is
like comparing `a + b + c` versus `(a + b) + c`.
Or for that matter:
a + b + c
versus
(((((((a) + (b)))) + (((c))))))
You can add all the redundant parentheses you like without changing the
order of operation.
Does this conversation have a point? You keep dropping hints that you
want to introduce a semantic difference between `obj.meth` and
`(obj.meth)`. Care to tell us what that difference is supposed to be?
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/632ZWF5Y3ZONF55NCIT6WDE66TR6HETH/
Code of Conduct: http://python.org/psf/codeofconduct/