Hashable data types

Currently there is no concept of "hashable" data types in ES. Hashable data types would be similar to primitives and their "hash" could be used for different kind of operations ===, Map keys, Set entires, etc.

The concept would allow to be added different data structures which are more complex than the primitives.
E.g. Records and Tuples , ranges , etc.

I'm looking forward to hearing your opinion.

Hey @abozhilov

As you mentioned records and tuple data types, have you seen the proposal looking specifically at that: GitHub - tc39/proposal-record-tuple: ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!

Related: https://github.com/tc39/proposal-symbols-as-weakmap-keys

Hey @aclaymore,

I've seen the proposals for Records and Tuples and I wouldn't call them primitives as they are composed types.

That's why I think the spec and the language should have a concept for hashable data types.

It would be a better terminology and it could allow adding new complex types without calling them primitives.

Hashable types are only a concept and they don't require implementation changes, only on spec level could be defined.

Immutable types as long as their internal "hash" is not changing during their lifetime could be defined as hashable and should be safe to use them as Map keys, Set entries and for structural comparison with ===.

They are primitives by the language’s definition of the term; being composed doesn’t make them not primitives - strings are composed of other strings.

Great that’ve you’ve also seen those other proposals.

Do you think you could share some rough code samples of what hashable data types might look like if you had some ideas?

Following your logic we can say that the numbers are composed by other numbers on a grammar level, but that's not the case with Tupples and Records.
Both types are composed by different primitive types and in my opinion they break the meaning of "primitive".

The current proposal for Records and Tuples uses the feature of primitive types in several operations and it seems that is the reason to be called primitives.

Anyway, if you and other members think it is inappropriate to be added the concept for hashable types I can live without it.