osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About the implementation of del in Python 3


On Fri, 7 Jul 2017 01:41 am, Marko Rauhamaa wrote:

> Here's how identity is dealt with in First-Order Logic:
> 
>    <URL: https://en.wikipedia.org/wiki/First-order_logic#Semantics>
> 
> In other words, identity is mapped to the "sameness" in a domain of
> discourse.


Define "sameness".



> In Second-Order Logic, you can define identity directly:
> 
>     ?x ?y x = y ? ?P (P(x) ? P(y))

Translating to English:

For all x, for all y, x equals y if and only if for all P
(P(x) if and only if P(y))


That might be sufficient for second-order logic, but it won't do for
programming. Defining if-and-only-if for functions that can return more than
two values (true and false) requires having a definition of equality, which
would make the definition circular.

And what if there exists even a single non-deterministic function, or one that
has hidden variables that may change state, or a constant function that always
returns the same value? Such things are forbidden in second order logic but
they exist in many programming languages.


> Programming languages are different beasts, of course, but "objects" and
> "identity" are such important foundational topics that you'd expect a
> bit more than hand-waving when defining the data model.

I wouldn't. I don't think identity is even capable of vigorous definition
outside of pure mathematics, and even if it is, I don't see how it would make
anyone a better programmer to have such a definition.

In practice, identity is hardly important in Python, except for a few limited
cases, and the prohibition against using `is` when you mean `==`.


 
> As a good example of the style I'm looking for, take a look at:
> 
>    <URL: https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html>

Neither the word "identity" nor "identical" exists on that page, so I don't see
how that solves your problem.




-- 
Steve
?Cheer up,? they said, ?things could be worse.? So I cheered up, and sure
enough, things got worse.