why () is () and [] is [] work in other way?

rusi rustompmody at gmail.com
Thu Apr 26 10:18:19 EDT 2012


On Apr 26, 4:42 pm, Adam Skutt <ask... at gmail.com> wrote:
>
> In a mathematical sense, you're saying that given f(x) = x+2, using
> f(x) is somehow more "direct" (whatever the hell that even means) than
> using 'x+2'.  That's just not true.  We freely and openly interchange
> them all the time doing mathematics.  Programming is no different.

If f(x) and x+2 are freely interchangeable then you have referential
transparency, a property that only purely functional languages have.
In python:
>>> a = [1,2]
>>> m1 = [a, a]
>>> m2 = [[1,2],[1,2]]

may make m1 and m2 seem like the same until you assign to m1[0][0].
eg One would not be able to distinguish m1 and m2 in Haskell.

On the whole I whole-heartedly agree that  'a is b' be replaced by
id(a) == id(b), with id itself replaced by something more obviously
implementational like addrof.

The reasons are fundamental:  The word 'is' is arguably the primal
existential verb.  Whereas 'is' in python is merely a leakage of
implementation up to the programmer level:
http://www.joelonsoftware.com/articles/LeakyAbstractions.html

Such a leakage may be justified just as C allowing inline asm may be
justified.
However dignifying such a leakage with the primal existential verb
causes all the confusions seen on this thread (and the various
stackoverflow questions etc).




More information about the Python-list mailing list