Why maintain comparisons between different data types based on (apparently) arbitrary rules?

My questions are: "Why does the language developer consider the possibility of comparison between different types of data?" Also, does this make sense in a functional language?

For example, in erlang you can make the following comparisons:

%% Tuples are greater than numbers
999999 < {1,2}.
true

%% Lists are greater than tuples
{90000} < [1].
true

%% Atoms are greater than numbers
1 < false.
true

In python 2.x also

p = lambda x,y: x+y

p > (1)
True

p < (1)
False

p == (1)
False

Although it seems like the python community has decided that this is not a good idea:

objects of different types are always compared unequal and ordered sequentially, but arbitrarily. [...] This unusual definition of comparison was used to simplify the definition of operations, such as sorting and not in operators. source

From the Python 3 release notes:

(<, < =, > =, > ) TypeError . , , 1 < '', 0 > len <= len None < TypeError , False. , - .

, , , , , .

+3
1

, . , , , , .

+1

All Articles