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

OKB (not okblacke) brenNOSPAMbarn at NObrenSPAMbarn.net
Thu Apr 26 22:56:24 EDT 2012


Adam Skutt wrote:

> If I write a function that does a value comparison, then it should
> do value comparison on _every type that can be passed to it_,
> regardless of whether the type is a primitive or an object, whether
> it has value or reference semantics, and  regardless of how value
> comparison is actually implemented.  If I write some function:
>     f(x : T, y : U) => x == y
> where T and U are some unknown types, then I want the function to
> do a value comparison for every type pairing that allows the
> function to compile.  Likewise, if I write a function that does
> identity comparison, then it logically wants to do identity
> comparison on _every type that can be passed to it_.

    	What you say here makes perfect sense, but also shows that you 
really shouldn't be using Python if you want stuff to work this way.  In 
Python any value of any type can be passed to any function.  The claims 
you are making about object identity and object equality are reasonable, 
but as you show here, to really handle them requires dragging in a huge 
amount of type-system baggage.  Python's behavior is perfectly well-
defined.  You might think it's not the best way to do it based on 
abstract conceptual frameworks for how programming languages "should" 
work, but it works just fine.


-- 
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail."
	--author unknown



More information about the Python-list mailing list