garrison

garrison

Lexicographic order is more expressive. If you wanted to model your vec2 < vec3 then you would do this:

@type vec2 :: {2, float(), float()}
@type vec3 :: {3, float(), float(), float()}

And they would sort properly (with the same performance characteristics!).

Going the other way would necessitate padding all tuples to a particular size, but that implies you actually know the size of the largest tuple in advance, which is unreasonable.

1
Post #11
rvirding

rvirding

Creator of Erlang

That was my point!

0
Post #12
bjorng

bjorng

Erlang Core Team

Yes, that is what Erlang used to do a long time ago. Someone in the HiPE team at Uppsala university pointed out that it would be much more useful to compare binaries in the same way as lists, so we silently changed that in next major release.

Yes, I agree. Tuples is usually used for holding a collection of values of a fixed size. For many use cases, the exact order in which tuples are ordered is not important. Therefore, I think the design decision to sort tuples by size first is the correct one.

1
Post #13
— All posts loaded —